私は既存のTabHostsのリファクタリングを実行しようとしているプロジェクトがあります。私は以下のような非常にシンプルなTabHostファイルをたくさん持っています。実際には1つのタブしか持たないものもあれば、3つのものもあります。実際には唯一の違いは、タブの数とそれぞれにロードされるアクティビティクラスです。私はちょうどいくつかのタブと情報(スペック、インジケータ、コンテンツ)を構築/各タブを追加するためにいくつかの情報を決定するために渡された情報を得ることができる単一のTabHostを作成したいと思います。私はバンドルに置くことができる項目はかなり基本的で、私はParcelableまたはSerializableの機能に慣れていないようです。助言がありますか?Android - バンドルの問題を使用して情報を渡す、一般的なTabHostを作成する
public class SomeTabHost
extends ActivityGroup
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Inflate ourselves into the layout ViewStub
ViewStub vs = (ViewStub) findViewById(R.id.theViewStub);
vs.setLayoutResource(R.layout.my_tabhost);
vs.inflate();
TabHost host = (TabHost) findViewById(android.R.id.tabhost);
host.setup(getLocalActivityManager());
host.addTab(host.newTabSpec("Tab1")
.setIndicator("Tab1")
.setContent(new Intent(this, SomeActivity.class)));
host.addTab(host.newTabSpec("Tab2")
.setIndicator("Tab2")
.setContent(new Intent(this, SomeOtherActivity.class)));
int numChildren = host.getTabWidget().getChildCount();
for (int i=0; i <numChildren; i++)
{
host.getTabWidget().getChildAt(i).getLayoutParams().height = 35;
}
}// end onCreate
}// end class