当我触摸此“编辑”按钮时,我希望它更改为“完成”。有没有办法做到这一点?
我试过这个,但它只在打开右侧的菜单时才有效:
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// change the text here.
return super.onPrepareOptionsMenu(menu);
}
当我触摸此“编辑”按钮时,我希望它更改为“完成”。有没有办法做到这一点?
我试过这个,但它只在打开右侧的菜单时才有效:
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// change the text here.
return super.onPrepareOptionsMenu(menu);
}
I assume that, at some point, you inflate the menu, yes?
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.some_menu_layout, menu);
return true;
}
So you can go into your menu (in this case, res/menu/some_menu_layout.xml
), and find the android:id
of the menu item you want to find. You should then be able to use menu.findItem(theId).setTitle("Done");
. (You may have to save your Menu
variable as a local member to do this.)