このコードを次のように切り戻しましたが、デフォルト以外のタブを取得して、そのタブに移動するときにそのビューを再描画することはできません (背景色などの一部の部分が正しく更新されていても)。コード以下です。
これを機能させるためのアドバイスをいただければ幸いです。選択したタブに応じて「モード 1」または「モード 2」が表示されますが、tabHost.setCurrentTab(1) で選択されたタブのみが表示されます。文字列は表示されますが、赤または青の境界線は更新されます。
// これがエントリーポイント /////////////////////////////////////
public class TabTest extends TabActivity
{ インテント インテント; バンドル パラメータ;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// テンプレート
インテント = 新しいインテント().setClass(this, TabContent.class); params = 新しいバンドル (); params.putString("タブ名", "モード 1"); インテント.putExtras(params); spec = tabHost.newTabSpec("Template").setIndicator("template",
res.getDrawable(R.drawable.tab_pane)) .setContent(intent); tabHost.addTab(仕様);
// ATTEMPT インテント = 新しいインテント().setClass(this, TabContent2.class); params = 新しいバンドル (); params.putString("TABNAME", "モード 2"); インテント.putExtras(params); spec = tabHost.newTabSpec("Attempt").setIndicator("attempt", res.getDrawable(R.drawable.tab_pane)) .setContent(intent); tabHost.addTab(仕様);
tabHost.setCurrentTab(1);
}
}
// タブ コンテンツ 1 ////////////////////////////////////
public class TabContent extends Activity { ScreenWrite s=null; SurfaceView screen_1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.content);
Bundle params = this.getIntent().getExtras();
String name = params.getString("TABNAME");
screen_1=(SurfaceView)findViewById(R.id.screen_1);
s=new ScreenWrite((Context)this, screen_1, name);
}
}
// タブ コンテンツ 2 ////////////////////////////////////
public class TabContent2 extends Activity { ScreenWrite s=null; SurfaceView screen_2;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.content2);
Bundle params = this.getIntent().getExtras();
String name = params.getString("TABNAME");
screen_2=(SurfaceView)findViewById(R.id.screen_2);
s=new ScreenWrite((Context)this, screen_2, name);
}
}
// コンテンツ レイアウト //////////////////////////////////////
// と ////////////////////////////////////////
//////////////////////////////////////
PSレイアウトは提出物から切り捨てられましたが、基本的には背景色と表面ビューの単なるホルダーです。明確でない場合は提供できます