Почему я вижу содержимое одной вкладки в другой вкладке - PullRequest
0 голосов
/ 23 июня 2011

Я пытаюсь реализовать три вкладки в моей программе для Android 2.2, я успешно реализовал 2 вкладки, но когда я добавляю третью, я вижу содержимое вкладки 2 в задней части вкладки 3. Первая вкладка представляет собойmap from google maps, 2-я вкладка - это функция поиска по карте, а третья - это действие с предпочтениями.

Я полагаю, что решение где-то в этом коде.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    // Adding tabbing feature
    mTabHost = getTabHost();
    TabSpec tabSpec = mTabHost.newTabSpec("Map1");
    tabSpec.setIndicator("Map1",
            getResources().getDrawable(R.drawable.globe));
    Context ctx = this.getApplicationContext();
    Intent i = new Intent(ctx, MapTabView.class);
    tabSpec.setContent(i);
    mTabHost.addTab(tabSpec);

mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
    .setIndicator("Filtered         Search",getResources().getDrawable(R.drawable.glass)).setContent(R.id.textview2));


TabSpec tabPref = mTabHost.newTabSpec("Preferences");
tabPref.setIndicator("Preferences",getResources().getDrawable(R.drawable.preferences));
Context ctx2 = this.getApplicationContext();
Intent l = new Intent (ctx2, Preferences.class);
tabPref.setContent(l);
mTabHost.addTab(tabPref);

и вот пример предпочтений xml, который я использую

<?xml version="1.0" encoding="utf-8"?>

    <PreferenceCategory
            android:title="First Category">
            <CheckBoxPreference
                    android:title="Checkbox Preference"
                    android:defaultValue="false"
                    android:summary="This preference can be true or false"
                    android:key="checkboxPref" />
            <ListPreference
                    android:title="List Preference"
                    android:summary="This preference allows to select an item in a array"
                    android:key="listPref"
                    android:defaultValue="digiGreen"
                    android:entries="@array/listArray"
                    android:entryValues="@array/listValues" />
    </PreferenceCategory>
    <PreferenceCategory
            android:title="Second Category">
    <EditTextPreference
            android:name="EditText Preference"
            android:summary="This allows you to enter a string"
            android:defaultValue="Nothing"
            android:title="Edit This Text"
            android:key="editTextPref" />
    <RingtonePreference
            android:name="Ringtone Preference"
            android:summary="Select a ringtone"
            android:title="Ringtones"
            android:key="ringtonePref" />
    <PreferenceScreen
            android:key="SecondPrefScreen"
            android:title="Second PreferenceScreen"
            android:summary="This is a second PreferenceScreen">
            <EditTextPreference
                    android:name="An other EditText Preference"
                    android:summary="This is a preference in the second PreferenceScreen"
                    android:title="Edit text"
                    android:key="SecondEditTextPref" />
    </PreferenceScreen>
    <Preference
            android:title="Custom Preference"
            android:summary="This works almost like a button"
            android:key="customPref" />
    </PreferenceCategory>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...