Je veux développer une application à onglets sur Android. En même temps, je souhaite que la fonctionnalité de recherche soit présente sur certains onglets. Pour cette raison, j'ai déclaré certaines activités dans le fichier manifeste et les ai ajoutées à TabHost. Mais le problème est que lorsque je fais une recherche, il appelle la méthode onCreate() de l'activité en cours qui réside dans le contenu de l'onglet. Ce que je veux, c'est que searchManager appelle la méthode onNewIntent() pour qu'une nouvelle activité ne soit pas créée et que je puisse gérer la recherche dans l'activité existante. Je poste mon fichier source manifeste et TabActivity pour être plus clair:Search crée de nouvelles activités dans TabActivity
Une partie du fichier manifeste:
<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>
Activité Tab onCreate Méthode:
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);
}
Je pense que ces deux bogues sont liés: http://code.google.com/p/android/issues/detail?id=17137 http://code.google.com/p/android/issues/detail? id = 4155 – Agos
avez-vous résolu cela? –