小编par*_*666的帖子

Android:没有TabActivity的TabHost

我想创建标签而不扩展TabActivity.(原因是TabActivity无法处理自定义标题栏).我有

public class startTab extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mylayout);
        Resources res = getResources();
        LocalActivityManager mlam = new LocalActivityManager(this, false);
        TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
        tabHost.setup(mlam);
        TabHost.TabSpec spec;
        Intent intent;

    intent = new Intent().setClass(this, Show1.class);
    spec = tabHost.newTabSpec("Items").setIndicator("Items", res.getDrawable(R.drawable.items32_ldpi)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, Show2.class);
    spec = tabHost.newTabSpec("Users").setIndicator("Users",res.getDrawable(R.drawable.user32_ldpi)).setContent(intent);
    tabHost.addTab(spec);
}
Run Code Online (Sandbox Code Playgroud)

}

我得到的错误是

    07-02 07:11:12.715: ERROR/AndroidRuntime(411): 
Caused by: java.lang.IllegalStateException: Activities can't be added until the containing group has been created.
Run Code Online (Sandbox Code Playgroud)

视图的xml是

<?xml version="1.0" encoding="utf-8"?> …
Run Code Online (Sandbox Code Playgroud)

android android-tabhost

42
推荐指数
2
解决办法
4万
查看次数

Android:自定义标题栏

我有一个自定义标题栏

 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
 setContentView(R.layout.activities);
 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Run Code Online (Sandbox Code Playgroud)

哪个工作基本上很好.问题是,在调用上面的代码之前,会显示默认标题栏.我根本不想要一个标题栏,换句话说,在我出现之前不会出现任何标题.

将此添加到清单:

<application android:theme="@android:style/Theme.NoTitleBar">
Run Code Online (Sandbox Code Playgroud)

导致力量关闭.我的清单看起来像这样

<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:theme="@style/My_Theme">
Run Code Online (Sandbox Code Playgroud)

我需要my_Theme,因为它设置了背景颜色,在我的客户主题中设置背景颜色会导致我的彩色背景周围的灰色区域.因此,即使没有力量关闭,我也不确定没有标题会有所帮助.

任何的想法?

谢谢.

layout android titlebar

11
推荐指数
1
解决办法
4万
查看次数

标签 统计

android ×2

android-tabhost ×1

layout ×1

titlebar ×1