Ich möchte eine Anwendung mit Tabs auf Android entwickeln. Gleichzeitig möchte ich, dass die Suchfunktionalität auf einigen Tabs vorhanden ist. Aus diesem Grund habe ich einige Aktivitäten in der Manifestdatei deklariert und zu TabHost hinzugefügt. Aber das Problem ist, dass wenn ich eine Suche mache, es onCreate() -Methode der aktuellen Aktivität aufruft, die sich im Tab-Inhalt befand. Ich möchte, dass der searchManager die onNewIntent() -Methode aufruft, so dass keine neue Aktivität erstellt wird und ich die Suche in vorhandenen Aktivitäten durchführen kann. Ich meine offenkundige und TabActivity Quelldatei Posting mehr klar zu sein:Die Suche erstellt neue Aktivitäten in TabActivity
Ein Teil der Manifest-Datei:
<activity
android:name="KarniyarikTabsWidget"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="UrunTab"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity android:name="ArabaTab" android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity android:name="GecmisTab" android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop">
</activity>
<activity android:name="HakkindaTab" android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop">
</activity>
Tab Aktivität onCreate Methode:
public class KarniyarikTabsWidget extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("UrunTab")
.setIndicator("Ürün",res.getDrawable(R.drawable.product))
.setContent(new Intent(this, UrunTab.class));
tabHost.addTab(spec);
//Do the same for other tabs
spec = tabHost.newTabSpec("ArabaTab")
.setIndicator("Araba",res.getDrawable(R.drawable.car))
.setContent(new Intent(this, ArabaTab.class));
tabHost.addTab(spec);
//Do the same for other tabs
spec = tabHost.newTabSpec("GecmisTab")
.setIndicator("Geçmiş",res.getDrawable(R.drawable.history))
.setContent(new Intent(this, GecmisTab.class));
tabHost.addTab(spec);
//Do the same for other tabs
spec = tabHost.newTabSpec("HakkindaTab")
.setIndicator("Hakkında",res.getDrawable(R.drawable.about))
.setContent(new Intent(this, HakkindaTab.class));
tabHost.addTab(spec);
}
Ich denke, diese beiden Bugs sind verwandt: http://code.google.com/p/android/issues/detail?id=17137 http://code.google.com/p/android/issues/detail? id = 4155 – Agos
hast du das gelöst? –