это мой код, который показывает три вкладки в верхней части экрана, , но не показывает никаких вкладок на экране, и у меня нет ни малейшего понятия, почему это происходит, может кто-нибудь понравится наставит меня здесь является XMLВкладки не отображаются с помощью tabhost
<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"
android:layout_marginTop="78dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:id="@android:id/tabcontent"
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" />
</LinearLayout>
</TabHost>
и вот код Java
final TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setCurrentTab(1);
final TabHost.TabSpec tab1 = tabHost.newTabSpec("First Tab");
final TabHost.TabSpec tab2 = tabHost.newTabSpec("Second Tab");
final TabHost.TabSpec tab3 = tabHost.newTabSpec("Third Tab");
tab1.setIndicator("Upcoming").setContent(new Intent(this, Upcoming_matches.class));
tab2.setIndicator("Recent").setContent(new Intent(this, Recent_matches.class));
tab3.setIndicator("Fixture").setContent(new Intent(this, Fixtures.class));
tabHost.addTab(tab1);
tabHost.addTab(tab2);
tabHost.addTab(tab3);
tabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams((int) Math.ceil((width/1)), 60));
tabHost.getTabWidget().getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams((int) Math.ceil((width/3)), 60));
tabHost.getTabWidget().getChildAt(2).setLayoutParams(new LinearLayout.LayoutParams((int) Math.ceil((width/3)), 60));
Найден ответ, с помощью @ Дон, это был в основном неправильно макет, framelayout был ниже, чем TabWidget, здесь правильный XML
<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"
android:layout_marginTop="78dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<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="wrap_content" />
</LinearLayout>
</TabHost>
Вы определили деятельность в манифесте? –
Да, его часть основного вида деятельности, другие компоненты работают так, как должны, кроме этого, если вы хотите полный код, я могу опубликовать его здесь – nullByte
TabHost устарел много лет. Вместо этого используйте TabLayout. –