开发者

An Exception occur in Tablayout

开发者 https://www.devze.com 2023-01-03 01:43 出处:网络
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;

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消