操作栏图标不在API 21中工作

时间:2015-02-15 16:27:54

标签: android

我过去常常使用操作栏图标,但是当我在API 21上执行某些操作时,没有显示任何图标我的意思是只有3个点而不是我想要的图标而我是api 14它正在工作:

菜单:

<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="com.example.gweltaz.idee.Historique">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
    android:orderInCategory="100"
    android:icon="@drawable/sup"
    app:showAsAction="ifRoom" />

活动

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_historique, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            db.execSQL("DELETE FROM story2");


            return true;
        }

        return super.onOptionsItemSelected(item);
    }

1 个答案:

答案 0 :(得分:0)

尝试更改:

app:showAsAction="ifRoom" />

app:showAsAction="always"/>