지금은 단일 활동과 별도의보기로 내 응용 프로그램 탭 호스트에서 사용하고 있습니다.TabHost 내부에서보기 변경 (하나의 활동, 여러보기)
탭 활동 :
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabs = (TabHost) findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec = tabs.newTabSpec(TAB_HOTELS);
spec.setContent(R.id.tab1);
spec.setIndicator("Hotels");
tabs.addTab(spec);
spec = tabs.newTabSpec(TAB_LAST_MINUTE);
spec.setContent(R.id.tab2);
spec.setIndicator("Last Minute");
tabs.addTab(spec);
레이아웃
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/tab1"
android:orientation="vertical">
<ListView android:id="@+id/listaLocalita"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/tab2"
android:orientation="vertical" android:paddingTop="60px">
<TextView android:layout_width="fill_parent"
android:layout_height="100px" android:text="This is tab 2"
android:id="@+id/txt2" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
그리고 내가 한 단계 깊이를 사용하고 같은 일이 아주 잘 한 노력하고 있습니다. 불행히도 다음과 같이 작동하도록 탭 중 하나를 만들어야합니다.
탭로드 ListView는 도시 목록, 도시 이름에 대한 사용자 클릭, 탭의 내용은 호텔 목록으로 대체되며 사용자는 호텔을 선택하고 항상 같은 탭에서 호텔의 정보가로드됩니다.
이 시나리오를 어떻게 달성 할 수 있습니까? LayoutInflater?
미리 감사드립니다.
혹시 이것을 알아 냈습니까? 나는 비슷한 것을하고있다. –
[이 예] (http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html)를 참조하십시오. 희망이 당신을 도울 것입니다. –