I am not sure I understood your question. I guess that you want to dynamically change the action items in your action bar.
Use the onPrepareOptionsMenu() method.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuItem item = menu.findItem(R.id.action_delete);
//show the action item
if (your condition) {
item.setEnabled(true);
item.setVisible(true);
}
super.onPrepareOptionsMenu(menu);
return true;
}
You should also override the invalidateOptionsMenu() method from the Activity class This will declare that the options menu has changed, and it will call the onPrepareOptionsMenu method to recreate the menu.