我已将此 cade 缩减为以下内容,但我仍然无法让非默认选项卡重新绘制它在移动到其选项卡时的视图(即使某些部分(例如背景颜色)已正确更新。代码在下面。
我将非常感谢有关使其正常工作的任何建议。它应该根据所选选项卡显示“模式 1”或“模式 2”,但仅在 tabHost.setCurrentTab(1) 中选择的选项卡;曾经显示字符串但红色或蓝色边框确实更新。
// 这是入口点 //////////////////////////////////
公共类 TabTest 扩展 TabActivity
{ Intent 意图;捆绑参数;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// 模板
意图 = new Intent().setClass(this, TabContent.class); 参数 = 新捆绑();params.putString("TABNAME", "模式 1"); 意图.putExtras(参数);spec = tabHost.newTabSpec("Template").setIndicator("template",
res.getDrawable(R.drawable.tab_pane)) .setContent(intent); tabHost.addTab(spec);
// ATTEMPT intent = new Intent().setClass(this, TabContent2.class); 参数 = 新捆绑();params.putString("TABNAME", "模式 2"); 意图.putExtras(参数);spec = tabHost.newTabSpec("Attempt").setIndicator("attempt", res.getDrawable(R.drawable.tab_pane)) .setContent(intent); tabHost.addTab(spec);
tabHost.setCurrentTab(1);
}
}
// 标签内容一 /////////////////////////////////
公共类 TabContent 扩展 Activity { ScreenWrite s=null; SurfaceView 屏幕_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);
}
}
// 标签内容二 /////////////////////////////////
公共类 TabContent2 扩展 Activity { ScreenWrite s=null; SurfaceView 屏幕_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 布局从提交中被截断,但基本上只是背景颜色和表面视图的持有者。不清楚可以提供