SearchView似乎不太好(?)

时间:2014-10-29 11:55:17

标签: android searchview android-appcompat

注意:我使用AppCompat 21,ActionBarActivity.Not toolBar,我放弃了。 :(

看起来令人耳目一新的ActionView非常快。 如果我花费了SearchView,在statusBar中,键盘图标会闪烁非常大。

这是代码。

main.xml中(RES /菜单/)

<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="kr.ApiMaster3525.DICE.OffLine.ui.DrawerActivity" >

    <item android:id="@+id/action_search"
        android:title="Search"
        android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
        app:showAsAction="always|collapseActionView"
        app:theme="@style/MySearchViewStyle"
        app:actionViewClass="android.support.v7.widget.SearchView" />

</menu>

DrawerActivity.java

    @Override
public boolean onCreateOptionsMenu(Menu menu)
{
    if (!mNavigationDrawerFragment.isDrawerOpen())
    {
        // Only show items in the action bar relevant to this screen
        // if the drawer is not showing. Otherwise, let the drawer
        // decide what to show in the action bar.
        getMenuInflater().inflate(R.menu.main, menu);
        menu.findItem(R.id.action_controller).setChecked(sharedPreferences.getBoolean("SETTING_CONTROLLER", false));
        menu.findItem(R.id.action_statusbar_controller).setChecked(sharedPreferences.getBoolean("SETTING_STATUSBAR", false));
        menu.findItem(R.id.action_actionbar_controller).setChecked(sharedPreferences.getBoolean("SETTING_ACTIONBAR", false));
        menu.findItem(R.id.action_music_controller).setChecked(sharedPreferences.getBoolean("SETTING_MUSIC", true));
        supportInvalidateOptionsMenu();
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

0 个答案:

没有答案