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;
}
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;
}
相关文章推荐
- SlidingDrawer引发java.lang.IllegalArgumentException: The content attribute is must refer to an existin
- TabHost添加3个及以上tab时报的异常(you must specify a way to create the tab content)及其他
- java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the
- Java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the
- Caused by: java.lang.IllegalArgumentException: The handle attribute is must refer to an existing chi
- java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with ...
- you must specify a way to create the tab indicator.
- java.lang.IllegalArgumentException: attempt to create delete event with null entity
- 错误:java.lang.IllegalArgumentException: attempt to create create event with null entity
- java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
- java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
- 解决kylin报错:Failed to create dictionary on <db>.<table>, Caused by: java.lang.IllegalArgumentException: Too high cardinality is not suitable for dictionary
- java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity异常的易被忽略的原因
- java.lang.IllegalArgumentException: AppIndex: The URI host must match the package name and follow th
- add bindNull to SQLiteDirectCursorDriver to avoid java.lang.IllegalArgumentException: the bind valu
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
- Android开发丶Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or
- java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决