実際のタブを適応させて、フラグメントを使用せずにスワイプ可能なタブを作成できるかどうかを知りたいのですが。
現在、スワイプできないタブがあります(各タブには無限のリストが含まれています:NewsList)。
スワイプできないタブに使用するコードは次のとおりです。
tabHost = (TabHost)this.findViewById(R.id.scrollTabs);
// Avant d’ajouter des onglets, il faut impérativement appeler la méthode
// setup() du TabHost
LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false);
mLocalActivityManager.dispatchCreate(savedInstanceState);
tabHost.setup(mLocalActivityManager);
// Ajoute un onglet pour chaque catégorie de news
tabNewslist = new NewsList[NewsCategory.values().length];
View tabView;
for (int i = 0; i < NewsCategory.values().length; i++) {
tabView = createTabView(tabHost.getContext(), NewsCategory.getValueAt(i).getName());
tabNewslist[i] = new NewsList(this, new LinkedList<Item>(), IdUrlRss.NEWSLIST, NewsCategory.getValueAt(i));
tabHost.addTab(tabHost.newTabSpec(NewsCategory.getValueAt(i).getName()).setIndicator(tabView).setContent(tabNewslist[i]));
}
そして、これがXMLレイアウトです。
<?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">
<HorizontalScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
NewsList用のPagerAdapterも作成しようとしましたが、失敗しました。