How can i show the up arrow when i press the searchbutton in my actionbar?
this is what i want
this is in my activity's oncreate:
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
this is in my styles.xml:
<style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:icon">@drawable/ic_launcher</item>
<item name="android:homeAsUpIndicator">@drawable/ic_launcher</item>
<item name="homeAsUpIndicator">@drawable/ic_launcher</item>
</style>
this is in my menu.xml
<item android:id="@+id/searchGrid"
android:title="@string/search_hint"
android:icon="@drawable/ic_action_search"
app:showAsAction="collapseActionView|ifRoom"
app:actionViewClass="android.support.v7.widget.SearchView"/>
manifest file:
<activity
android:theme="@style/Theme"
android:launchMode="singleTop"
android:name=".MainActivity"
android:label="@string/app_name" >
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
OncreateOptionsMenu method:
this.menu = menu;
getMenuInflater().inflate(currentActionBar, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =(SearchView) menu.findItem(R.id.searchGrid).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true);
searchView.setInputType(InputType.TYPE_CLASS_NUMBER);
return true;
Build.gradle dependencies:
compile 'com.android.support:appcompat-v7:21.0.3'
Thank you so much if you guys could solve this for me, i've been searching for hours.