activity_main_actions.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:title="@string/actions_search"/>
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_action_share"
android:showAsAction="ifRoom"
android:title="@string/actions_share"/>
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_action_settings"
android:showAsAction="never"
android:title="@string/actions_settings"/>
</menu>
Main_Activity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main_actions, menu);
return super.onCreateOptionsMenu(menu);
}
我试图让搜索和分享图标显示在操作栏上,设置显示在溢出中但这就是我得到的
答案 0 :(得分:0)
它有效,我换了
机器人:showAsAction = “总是” 同 应用程式:showAsAction = “总是”