这是我的ActionBar菜单的xml文件。调用setContentView
MenuItem的findViewById返回null
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/fav_button"
android:title="Favourite"
android:icon="@drawable/unstar"
android:showAsAction="always|withText" />
</menu>
在我onCreate
功能,后。我做favButton = (MenuItem) this.findViewById(R.id.fav_button);
但是这返回null。
但是返回onOptionsItemSelected
函数上的正确对象。
我使用ActionBarSherlock,如果这会有所作为。
我尝试过其他findViewById建议的各种选项,返回空问题,但它们还没有解决我的问题。
http://www.vogella.com/articles/AndroidActionBar/article.html。检查链接。 – Raghunandan 2013-05-11 18:32:34