0
android ActionBarに問題があります。私はメニューボタンで到達できるオプションを作成しました。私は、右側のActionBarにある別のボタンを使用したいと思います。私はこれについてたくさん読んで、ほとんどすべてを試しましたが、うまくいきません。ActionBarにmenubuttonを置く方法
menu_gallary.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="hu.redbuttonebb.endi.fragmentek20.MainActivity">
<item
android:orderInCategory="79"
android:title="@string/action_settings"
android:icon="@drawable/ic_action_overflow"
app:showAsAction="ifRoom">
<menu>
<item
android:id="@+id/create_new"
android:title="Album hozzáadása"
app:showAsAction="always"
android:orderInCategory="100"/>
</menu>
</item>
GalleryFragment.java:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.menu_gallery, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.create_new:
Toast.makeText(getActivity(),
"It worked ",
Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
誰もが知っていれば私が間違って下さい応答を何をしますか。
あなたは 'showAsActionを使用している場合、オーバーフローアイコンが自動的に表示されます:十分なスペースと' showAsAction =があるアクションバー –
に十分なスペースがない場合は「決して」や ''動作しませんでした「決して」。 –