Java 如何在没有TabActivity的情况下设置自定义tabhost样式
我在没有tab活动的情况下设置tab, 所以我的tabHost总是有一个错误。 请告诉我怎么做。 谢谢Java 如何在没有TabActivity的情况下设置自定义tabhost样式,java,android,user-interface,Java,Android,User Interface,我在没有tab活动的情况下设置tab, 所以我的tabHost总是有一个错误。 请告诉我怎么做。 谢谢 private void setupTab(类CCL、字符串名称、字符串标签、, 整数(iconId){ Intent Intent=new Intent().setClass(这是ccls); 视图选项卡=LayoutFlater.from(this).充气(R.layout.custom_选项卡,空); ImageView image=(ImageView)tab.findViewById
private void setupTab(类CCL、字符串名称、字符串标签、,
整数(iconId){
Intent Intent=new Intent().setClass(这是ccls);
视图选项卡=LayoutFlater.from(this).充气(R.layout.custom_选项卡,空);
ImageView image=(ImageView)tab.findViewById(R.id.icon);
TextView text=(TextView)tab.findViewById(R.id.text);
if(iconId!=null){
image.setImageResource(iconId);
}
text.setText(标签);
TabSpec spec=tabHost.newTabSpec(名称).setIndicator(选项卡)
.setContent(意图);
tabHost.addTab(spec);
}
我读
挣钱是不可能的。
无法解决tabHost运行错误。打印日志,记录错误是什么。
private void setupTab(Class<?> ccls, String name, String label,
Integer iconId) {
Intent intent = new Intent().setClass(this, ccls);
View tab = LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
ImageView image = (ImageView) tab.findViewById(R.id.icon);
TextView text = (TextView) tab.findViewById(R.id.text);
if (iconId != null) {
image.setImageResource(iconId);
}
text.setText(label);
TabSpec spec = tabHost.newTabSpec(name).setIndicator(tab)
.setContent(intent);
tabHost.addTab(spec);
}