An Exception occur in Tablayout
I wanna add three layout in a TabActivity, but it was force closed when I ran it.
Here is the code:
import android.app.TabActivity; import android.content.res.Resources; import android.os.Bundle; import android.widget.TabHost;
public class Test1 extend开发者_开发知识库s TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("egcquery").setIndicator("EGCQuery").setContent(R.layout.main1));
tabHost.addTab(tabHost.newTabSpec("PatientInfo").setIndicator("PatientInfo").setContent(R.layout.main2));
tabHost.addTab(tabHost.newTabSpec("Comp_Interp").setIndicator("Comp_Interp").setContent(R.layout.main3));
}
}
See my answer to this question: Why do I get an error while trying to set the content of a tabspec in android?
精彩评论