如何在tabhost中显示日历视图? PLS

时间:2014-08-24 16:50:22

标签: android android-tabhost android-calendar

我想在tab3中显示日历视图,但我不知道

mainActivity.class

    public MainActivity extends ActionBarActivity {
    TabHost mTabHost;


    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    CalendarView calendarView = new CalendarView(this);



    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB1")
    .setContent(R.id.tab1));
      mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB2")
     .setContent(R.id.tab2));
      mTabHost.addTab(mTabHost.newTabSpec("Calendar").setIndicator("TAB3")
     .setContent(R.id.tab3));
     mTabHost.setCurrentTab(0);
       }
          }

main_activity.xml它包含tabHost小部件

<TabHost
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            ref tab 1-3

            <include layout="@layout/activity_tab1" />
            <include layout="@layout/activity_tab2" />
            <include layout="@layout/activity_tab3" />
        </FrameLayout>

    </LinearLayout>
</TabHost>'

tab3.xml这个点击我想在其中显示日历。

  <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout

    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <CalendarView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cldView" />

  </LinearLayout>
    </RelativeLayout>

向我提出建议。

0 个答案:

没有答案