@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.viewtest1:
Intent i = new Intent(DynamiclistviewActivity.this, ConfigActivity.class);
i.putExtra("Value1",value1);
i.putExtra("Value2",value2);
i.putExtra("Value3",value3);
i.putExtra("Value4",value4);
i.putExtra("Value5",value5);
// Set the request code to any code you like, you can identify the
// callback via this code
startActivityForResult(i, REQUEST_CODE);
break;
case R.id.viewtest2:
Intent i2 = new Intent(DynamiclistviewActivity.this, loginActivity.class);
i2.putExtra("Value1","dummy");
startActivityForResult(i2, REQUEST_CODE2);
break;
}
return true;
}
Once the activity is created, the onCreateOptionsMenu() method is called only once, as described above. The system keeps and re-uses the Menu you define in this method until your activity is destroyed. If you want to change the Options Menu any time after it's first created, you must override the onPrepareOptionsMenu() method. This passes you the Menu object as it currently exists. This is useful if you'd like to remove, add, disable, or enable menu items depending on the current state of your application.
@Override
public boolean onPrepareOptionsMenu (Menu menu) {
if (loginpass) // loginpass is a boolean that will be changed in other part of the program
menu.getItem(1).setEnabled(false);
return true;
}