I have a SearchView implementation that's not working at all. I have tried a lot of things, but nothing is working.(this,this and other answers) What am I doing wrong? I am trying to log the partial results or something that tells me it is working, but I don't get anything.
Manifest.xml
<activity
android:name=".MapaActivity"
android:label="@string/title_activity_mapa"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
</intent-filter>
</activity>
menu.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="com.buweb.bu.MapaActivity">
<item android:id="@+id/search"
android:title="@string/menu_search"
android:icon="@android:drawable/ic_menu_search"
app:showAsAction="collapseActionView|ifRoom"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>
Activity
public class MapaActivity extends BaseActivity implements OnMapReadyCallback, SearchView.OnQueryTextListener {
... //A lot of code doing stuff with map.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_mapa, menu);
MenuItem searchItem = menu.findItem(R.id.search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
Log.d("", "query:" + query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d("", "query:" + newText);
return false;
}