How to get menu item id on action bar when other menu item clicked
pSo I have menu items on action bar. on onOptionsItemSelected, I want to
change the menu items images. /p pHere's my code/p precode @Override
public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on
the action bar items switch (item.getItemId()) { case R.id.todaySched:{
viewTodaySched(); item.setIcon(R.drawable.calendarselected);
infoLog=(MenuItem)findViewById(R.id.infoLog);
infoLog.setIcon(R.drawable.book); return true;} case R.id.infoLog:{
viewInfoLog(); item.setIcon(R.drawable.bookselected);
todaySched=(MenuItem)findViewById(R.id.todaySched);
todaySched.setIcon(R.drawable.calenderselected); return true;} default:
return super.onOptionsItemSelected(item); } } /code/pre pBut the icon
won't change when I clicked it, and I got run time error. e.g: When I
click todaySched icon, It seems like I can't get the infoLog item id. /p
pMy LogCat: a href=https://www.dropbox.com/s/0wfz0ogkh57vbtz/log.txt
rel=nofollowLogCat/a/p
No comments:
Post a Comment