<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"/>
</menu>
enter a label for your option in
android:title="@string/action_settings
==============================================================
and type this coding in your layout java page
// this for create a menu in the layout
public boolean onCreateOptionsMenu(Menu menu) {
=============================================================
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.page, menu);
return true;
}
//to catch the click option from the menu to identify which option selected
// import MenuItem Library also
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_settings:
//if action_setting id is chosen it will cal newproductactivity class
Intent i = new Intent(getApplicationContext(), NewProductActivity.class);
startActivity(i);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
===================================================
now we have one option in option menu
import MenuItem Library also
Create Option Menu in Android Application
Create Option Menu in Android Application
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_settings" android:orderInCategory="100" android:title="@string/action_settings"/> </menu>
Call Another Activity From one Activity in Android Development
package com.one.click;//Package name
//libraries want to import
import android.R.string;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainScreenActivity extends Activity{
//Declare a button
Button btnNewProduct;
//declare a layout which is want to open when this class called
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);//here is the place to enter layout name
// Buttons assign the id of the buton in our layout
btnNewProduct = (Button) findViewById(R.id.btnCreateProduct);
// here is the place show when click btnNewProduct buton which class want to open btnNewProduct.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Launching create new product activity
Intent i = new Intent(getApplicationContext(), NewProductActivity.class);
startActivity(i);
}
});
}
Call Another Activity From one Activity in Android Development
to Open new activity or page
here is the android code to open new activity from one another activity
here is the android code to open new activity from one another activity
Subscribe to:
Posts (Atom)