0

タブベースのアプリを作成しました。タブの1つに、アダプターを使用して一部のデータを表形式で表示する内部タブもあります。Android2.1を搭載したすべてのデバイスで完全に問題ありません。ただし、Android 2.2デバイスを搭載したすべてのデバイスでは、最初のタブのみが表示され、上の黒い画面のみが表示されます。参考までに2つの異なるスクリーンショットを示しました。

2.1デバイスのスクリーンショット

2.1デバイスのスクリーンショット

2.2デバイスのスクリーンショット

2.2デバイスのスクリーンショット

タブアクティビティのXML

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:id="@+id/myinfotrackerlayout"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"/>
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:gravity="bottom" 
            android:isScrollContainer="false" 
            android:scrollbarAlwaysDrawHorizontalTrack="false" 
            android:scrollbarAlwaysDrawVerticalTrack="false" 
            android:scrollbars="none"
            android:background="#FFFFFF"/>
    </LinearLayout>
</TabHost>

タブアクティビティのコード

public class MyInfoTracker extends TabActivity {
    private int tabid = 0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myinfotracker);
        try{
            final TabHost innerTabHost = getTabHost();  // The activity TabHost
            TabHost.TabSpec spec;  // Resusable TabSpec for each tab

            Intent intent;  // Reusable Intent for each tab
            Intent myint = this.getIntent();
            tabid = myint.getIntExtra("tab_id", 0);

            // Create an Intent to launch an Activity for the tab (to be reused) 
            intent = new Intent().setClass(this, MyinfoActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
            intent.putExtra("addType","CD4");

            // Initialize a TabSpec for each tab and add it to the TabHost
            spec = innerTabHost.newTabSpec("CD4Count").setIndicator("CD4 Count").setContent(intent);
            innerTabHost.addTab(spec);

            // Do the same for the other tabs
            intent = new Intent().setClass(this, MyinfoActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
            intent.putExtra("addType","VL");
            spec = innerTabHost.newTabSpec("ViralLoad").setIndicator("Viral Load").setContent(intent);
            innerTabHost.addTab(spec);

            // Do the same for the other tabs
            intent = new Intent().setClass(this, MyinfoActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
            intent.putExtra("addType","Wt");
            spec = innerTabHost.newTabSpec("Weight").setIndicator("Weight").setContent(intent);
            innerTabHost.addTab(spec);

            innerTabHost.setScrollbarFadingEnabled(false);
            innerTabHost.setScrollContainer(false);

            innerTabHost.setCurrentTab(tabid);
        }catch(Exception e){}
    }
}

このタイプの問題の原因は何ですか?

4

1 に答える 1

0

タブに関連する問題ではありません。コードonCreate()があります-

datePickerDialog = new DatePickerDialog(getParent(), ButtonTestDateListener,
                mYear, mMonth, mDay);

とを整数として宣言しました がmYear、初期化はありませんでした。2.1では正常に動作していますが、2.2では問題が発生します。それがそのような問題を与えている理由です。mMonthmDay

于 2011-07-01T12:32:12.863 に答える