您的位置:首页 > 编程语言 > Java开发

java.lang.IllegalArgumentException: you must specify a way to create the tab content

2015-03-18 20:08 645 查看
今天遇到了这个问题

java.lang.IllegalArgumentException: you must specify a way to create the tab content

解决办法:

TabHost tab_host = null;

LayoutInflater inflater = null;

@SuppressWarnings("deprecation")

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initTabsView();

}

@SuppressWarnings("deprecation")

public void initTabsView(){

Intent intent = new Intent(this,PersonActivity.class);//添加intent

inflater = LayoutInflater.from(this);

tab_host = this.getTabHost();

for(int i =0;i<4;i++){

TabSpec tab_spec = tab_host.newTabSpec(ConValue.tab_text_info[i]);

tab_spec.setIndicator(getTabView(i));

tab_spec.setContent(intent);//根据tab content 来判断你是否添加了setContent

tab_host.addTab(tab_spec);

}

}

public View getTabView(int i){

View view = inflater.inflate(R.layout.tab_layout_info,null);

ImageView image = (ImageView)view.findViewById(R.id.tab_image);

image.setImageResource(R.drawable.user);

TextView text = (TextView)view.findViewById(R.id.tab_text);

text.setText(ConValue.tab_text_info[i]);

return view;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐