I have a searchView in my app that when you click on the search icon it displays searchView and the <-- button closes searchView. The code for displaying the <-- button is...
actionBar.setDisplayHomeAsUpEnabled(true);
What if statement would I need to code my <-- button so I can code what it does.
if(actionBar.setDisplayHomeAsUpEnabled(true)) {}
The above code doesn't work. There is also no...
if(actionBar.onClick){}
I'm looking for an if statement that says if that <-- button is clicked on, close the searchView.
if(onBackPressed){} //doesn't work either
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(android.R.id.home == item.getItemId()){
//write your code here
}
return super.onOptionsItemSelected(item);
}