今天遇到了这个问题
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;
}