Noo*_*oor 5 android android-menu android-drawable
我在菜单项中有一个书签图标.我想更改图标中的drawable,具体取决于之前是否按过书签.
我有两个标签,staro(意思是星橙)或starw(意思是星白).我只想在媒体上切换这个.
我如何知道public boolean onOptionsItemSelected(MenuItem item)方法中的图标中有哪个drawble .是否可以通过该项目了解drawable.我所知道的是item.getIcon()不是drawble.我不能比较item.getIcon()与R.drawable.starto
nic*_*cja 13
你可以试试
if (item.getIcon().getConstantState().equals(
getResources().getDrawable(R.drawable.starto).getConstantState()
)) {
...
}
Run Code Online (Sandbox Code Playgroud)
如前所述这里