I don't understand how, but it was working fine up till yesterday... now I changed some things around and happens that, whenever I type something in the Search box of my app on the top menu, every letter I type gets deleted immediately. If I paste a longer word, its letters are quickly deleted one by one -- I can see this from a callback function on setOnQueryTextListener: the function is called every time a letter is deleted, so if I paste a word with 5 letters, ie. "Hello", the function is quickly triggered with "Hello", "Hell", "Hel", "He", "H"...and my box is left empty.
I really can't think of any reason for this to happen.
This is how I implemented it.
menu_basic.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_basic_search"
android:actionViewClass="com.actionbarsherlock.widget.SearchView"
android:icon="@drawable/react_search"
android:showAsAction="ifRoom|collapseActionView"
android:title="@string/description_search"/>
<item android:id="@+id/menu_basic_menu"
android:title="@string/description_menu"
android:icon="@drawable/react_menu"
android:showAsAction="always" />
</menu>
on my fragment .java
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.menu_basic, menu);
(getSherlockActivity()).getSupportActionBar().setHomeButtonEnabled(true);
SearchManager searchManager = (SearchManager) getSherlockActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_basic_search).getActionView();
if (null != searchView )
{
searchView.setSearchableInfo(searchManager.getSearchableInfo(getSherlockActivity().getComponentName()));
searchView.setIconifiedByDefault(false);
}
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener()
{
@Override
public boolean onQueryTextChange(String newText)
{
Log.i("SEARCH newText", newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query)
{
Log.i("SEARCH query", query);
return true;
}
};
searchView.setOnQueryTextListener(queryTextListener);
}
Apart from this, I can't find any other reference I have to the SearchView on my code.
Any idea of where the issue could be?