I really don’t know how to solve this, I have found many many solutions but still it does not work.
My problem is after my activiy jump to TabHost, the tab pageview turn out blank, but when I switch the tab, it’s turn normal.
I guess the date has ready when the activity first jump, but why it doesn’t show normal?
Any help will very appreciate..
This it the activity where the jumped TabHost at.
public class ListContainActivity extends FragmentActivity{
public static final String tag = "COOLSMILE_DEBUG";
private TabHost tabHost ;
ContextTask contextTask ;
String mString="";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.showcontain);
ProgressRefresh();
}
private void InitUI(){
getIntentExtra();
Log.v(tag, "----------- InitUI start -----------");
InitTabHost();
}
private void InitTabHost(){
Log.v(tag, "----------- InitTabHost start -----------");
TabHost.TabSpec spec;
tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
spec=tabHost.newTabSpec("Refresh").setIndicator("Refresh").setContent(R.id.contain_tab0);
tabHost.addTab(spec);
spec=tabHost.newTabSpec("Love").setIndicator("Love").setContent(R.id.contain_tab1);
tabHost.addTab(spec);
spec=tabHost.newTabSpec("Comment").setIndicator("Comment").setContent(R.id.contain_tab2);
tabHost.addTab(spec);
spec=tabHost.newTabSpec("Onward").setIndicator("Onward").setContent(R.id.contain_tab0);
tabHost.addTab(spec);
spec=tabHost.newTabSpec("Goback").setIndicator("Goback").setContent(R.id.contain_tab1);
tabHost.addTab(spec);
InitClickListener();
}
private void ProgressRefresh(){
Log.v(tag, "----------- progress_refresh start -----------");
contextTask = new ContextTask(0);
TaskHost taskHost = new TaskHost(){
@Override
public void onPreExecute(int requestCode) {
// TODO Auto-generated method stub
super.onPreExecute(requestCode);
Log.v(tag, "----------- progress_refresh.onPreExecute() start -----------");
InitUI();
}
@Override
public void onPostExecute(int requestCode, String result) {
// TODO Auto-generated method stub
super.onPostExecute(requestCode, result);
Log.v(tag, "----------- progress_refresh.onPostExecute() start -----------"+result);
TextView txt = (TextView)findViewById(R.id.text_Result);
txt.setText("DoInBackground Result :"+result);
TextView txt1 = (TextView)findViewById(R.id.text_Refresh);
txt1.setText("Hello my name is "+mString);
}
};
contextTask.setTaskHost(taskHost);
contextTask.setProgress(new SimpleDialogProgress(this,"正在获取数据..."));
contextTask.execute();
}
private void InitClickListener(){
Log.v(tag, "----------- InitClickListener start -----------");
RadioGroup radioGroup=(RadioGroup) this.findViewById(R.id.main_tab);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
switch (checkedId) {
case R.id.main_tab_addHome:
tabHost.setCurrentTabByTag("Refresh");
break;
case R.id.main_tab_addExam:
tabHost.setCurrentTabByTag("Love");
break;
case R.id.main_tab_myExam:
tabHost.setCurrentTabByTag("Comment");
break;
case R.id.main_tab_message:
tabHost.setCurrentTabByTag("Onward");
break;
case R.id.main_tab_settings:
tabHost.setCurrentTabByTag("Goback");
break;
default:
tabHost.setCurrentTabByTag("Refresh");
break;
}
}
});
}
private void getIntentExtra(){
Intent intent = getIntent();
mString = intent.getExtras().getString("PRESIDENTS_CONTENT");
}
}
I have find the reason,it’s because the
TagandsetContent(R.id.contain_tab1)isn’t One-to-one relationship.I thought just set it one time before,now I have solve the question.