Why do I get an error while trying to set the content of a tabspec in android?

前端 未结 3 944
暗喜
暗喜 2020-12-18 07:37

I have an android activity in which I\'m using tabs.

public class UnitActivity extends TabActivity {
  @Override
  public void onCreate(Bundle savedInstanceS         


        
3条回答
  •  鱼传尺愫
    2020-12-18 07:48

    If you have your tab layout in a different file, you have to inflate the XML.

    spec = tabHost.newTabSpec("data");
    spec.setIndicator("Data");
    // Add the layout to your tab view
    getLayoutInflater().inflate(R.layout.unit_data, tabHost.getTabContentView(), true);
    spec.setContent(R.id.unit_data);   
    tabHost.addTab(spec);
    

提交回复
热议问题