Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在没有TabActivity的情况下设置自定义tabhost样式_Java_Android_User Interface - Fatal编程技术网

Java 如何在没有TabActivity的情况下设置自定义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

我在没有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(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);

}