我正在关注操作栏的谷歌教程,但图标没有出现在上面,这是菜单 xml 文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/action_refresh"
android:icon="@drawable/ic_action_refresh"
android:title="refresh"
android:showAsAction="ifRoom"/>
<item android:id="@+id/action_settings"
android:icon="@drawable/ic_action_settings"
android:title="settings"
android:showAsAction="ifRoom"/>
<item android:id="@+id/action_compose"
android:icon="@drawable/ic_action_new"
android:title="add"
android:showAsAction="ifRoom"/>
</menu>
这在我的主要活动中:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_bar, menu);
return super.onCreateOptionsMenu(menu);
}