I've cut this cade back to the following and I still have can't get the non-default tab to redraw it's view on moving to its tab (even though some parts, such as a background colour, are updated correctly. The code is below.
I would be extremely grateful for ay advice on getting this to work. It should show "Mode 1" or "Mode 2" depending on the selected tab but, only the tab selected in tabHost.setCurrentTab(1); ever shows the string BUT the red or blue border does update.
// THIS IS THE ENTRY POINT ////////////////////////////////////////
public class TabTest extends TabActivity
{
Intent intent;
Bundle params;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// TEMPLATE
intent = new Intent().setClass(this, TabContent.class);
params = new Bundle();
params.putString("TABNAME", "Mode 1");
intent.putExtras(params);
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 = new Bundle();
params.putString("TABNAME", "Mode 2");
intent.putExtras(params);
spec = tabHost.newTabSpec("Attempt").setIndicator("attempt",
res.getDrawable(R.drawable.tab_pane))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(1);
}
}
// Tab content one ////////////////////////////////////////
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);
}
}
// Tab content two ////////////////////////////////////////
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);
}
}
// The content layouts ////////////////////////////////////////
// and ////////////////////////////////////////
////////////////////////////////////////
PS the layouts were truncated from the submission but are essentially just holders for a background colour and surfaceview. Can supply if not clear