开发者

Why can I see one Tabs Content in another Tab

I am trying to get three tabs implemented in my program for android 2.2, I have successfully implemented 2 tabs but when I add a third I can see the contents from tab 2 in the back of tab 3. The first tab is a map from google maps, the 2nd tab is a map search feature and the third is a preference activity.

I figure the solution is somewhere in this code.

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);

and here is an example preferences xml I am using

<?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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜