Activité de recherche Android en activité unique

Je suis en train de faire mon application se composent d'une SEULE activité. Cette activité devrait être en mesure de créer une zone de recherche et également recevoir un recherche. Malheureusement, je suis un "double" de la barre de recherche dans mon SearchView quand je clique sur le bouton rechercher dans la barre d'action. Je veux dire qu'il y a une barre de recherche (dark-- SearchView) qui s'affiche pendant une seconde dans la barre d'action, puis un second (blanc) apparaît au-DESSUS de la barre d'action. Toute aide? Ce que je fais mal?
Désolé, cette recherche chose est tout nouveau et déroutant pour moi.

MainActivity (la seule activité):

public class MainActivity extends ActionBarActivity {
Menu mMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getSupportActionBar().setDisplayShowTitleEnabled(false);
setContentView(R.layout.activity_main);
handleIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
handleIntent(intent);
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
//use the query to search your data somehow
}
}
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mMenu = menu;
//Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.search:
onSearchRequested();
return true;
default:
return false;
}
}
@SuppressLint("NewApi")
@Override
public boolean onSearchRequested() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
MenuItem mi = mMenu.findItem(R.id.search);
if(mi.isActionViewExpanded()){
mi.collapseActionView();
} else{
mi.expandActionView();
}
} else{
//onOptionsItemSelected(mMenu.findItem(R.id.search));
}
return super.onSearchRequested();
}
}

main.xml (le menu xml):

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:com.brianco.andypedia="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/search"
android:title="@string/action_settings"
android:icon="@drawable/ic_launcher"
android:actionProviderClass="android.support.v7.widget.ShareActionProvider"
com.brianco.andypedia:showAsAction="always|collapseActionView"
com.brianco.andypedia:actionViewClass="android.support.v7.widget.SearchView" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

searchable.xml:

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />

dans le manifeste:

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
<activity
android:name="com.brianco.andypedia.MainActivity"
android:label="@string/app_name" >
<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>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<meta-data android:name="android.app.default_searchable"
android:value=".MainActivity" />

source d'informationauteur Eric Cochran