相关疑难解决方法(0)

尝试使用Window.FEATURE_CUSTOM_TITLE,但得到例外:您无法将自定义标题与其他标题功能组合在一起.

我正在尝试使用自定义标题在标题栏中包含图像按钮.我在这篇文章中得到了很多帮助:android:在应用程序的标题中添加按钮?,但无法使其适用于我的ListActivity.

简而言之,以下就是我所拥有的:

  1. 我隐藏了AndroidManifest.xml中的标题栏
  2. 指定自定义标题的相对布局(workorder_list_titlebar.xml)

  3. 我的活动类如下所示:

    public class WorkOrderListActivity extends ListActivity {
     String[] orders={"WO-12022009", "WO-12302009","WO-02122010", "02152010"};
     @Override
     public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);   
       requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
       this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.workorder_list_titlebar);
       setContentView(R.layout.workorder_list);
       setListAdapter(new ArrayAdapter(this,R.layout.workorder_list, R.id.label,orders));    
            }
    }

当我运行应用程序时,我得到了AndroidRuntimeException:您无法将自定义标题与其他标题功能组合在一起.

基于堆栈跟踪,com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183)抛出异常,该异常由setlistAdapter调用触发.

有没有人与ListActivity有同样的问题?此外,一旦我设法完成这项工作,我如何将监听器附加到图像按钮才能执行某些操作?

提前致谢.

android

16
推荐指数
3
解决办法
3万
查看次数

android.util.AndroidRuntimeException:您无法将自定义标题与其他标题功能组合在一起

嗨我的代码得到错误.你能告诉我如何解决这个问题吗?

样式代码

 <style name="AppTheme" parent="AppTheme.Base"/>
 <style name="AppTheme.Base" parent="Theme.AppCompat.Light">
Run Code Online (Sandbox Code Playgroud)

活动代码

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // To set the custom title with Button
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.create_account_screen_1);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
    R.layout.title_layout_with_two_button);

    ((TextView) findViewById(R.id.myTitle)).setText(R.string.create_acc);
//  ((Button) findViewById(R.id.back_button)).setText(R.string.login);
    ((Button) findViewById(R.id.right_button)).setVisibility(View.INVISIBLE);
Run Code Online (Sandbox Code Playgroud)

清单代码

<activity android:name=".CreateAccountActivity1" 
          android:theme="@style/AppTheme"/>
Run Code Online (Sandbox Code Playgroud)

**create_account_screen_1**

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#fafafa"
        android:orientation="vertical" >
        <View
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:background="@android:color/black"  />


        <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="right"
                android:orientation="vertical"
                android:paddingRight="5dp"
                android:paddingTop="3dp" 
                android:id="@+id/scrollview_bottom">
                <TextView 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="5sp"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:text="@string/step_1_2"  
                    android:visibility="gone"   />
                <TextView 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="5sp"
                    android:layout_marginTop="10sp"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black" …
Run Code Online (Sandbox Code Playgroud)

android android-activity

5
推荐指数
1
解决办法
5506
查看次数

您无法将自定义标题与其他标题功能组合使用

在我的应用程序中,我正在使用ActionBarSherlock库.我也在使用自定义标题栏.这是我的onCreate:

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

在我的styles.mxl

<style name="MyTheme" parent="Theme.Sherlock">
        <item name="android:background">#ff888888</item>
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">50dp</item>
        <item name="android:windowTitleBackgroundStyle">@style/windowTitleBackgroundStyle</item>
    </style>
<style name="windowTitleBackgroundStyle">  
  <item name="android:background">#00688B</item>                
</style>
Run Code Online (Sandbox Code Playgroud)

在Manifest文件中,我使用MyTheme进行活动.

android:theme="@style/MyTheme"
Run Code Online (Sandbox Code Playgroud)

此代码适用于较低的Android版本(我已使用GB2.3.5进行了测试).但是当我使用ICS进行测试时,它崩溃了以下错误:"你无法将自定义标题与其他标题功能结合起来"我在StackOVerflow讨论中进行了彻底的讨论,但无法解决问题.解决方案尝试:1)假2)没有值-v11文件夹

android actionbarsherlock android-actionbar

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

设置Window.FEATURE_CUSTOM_TITLE会创建AndroidRuntimeException

我似乎无法通过这个错误:

android.util.AndroidRuntimeException:您无法将自定义标题与其他标题功能组合在一起

我正在运行API> 14.

清单如下:

    <activity
        android:name=".activity.ActivityWelcome"
        android:label="@string/app_label_name"
        android:launchMode="singleTask"
        android:clearTaskOnLaunch="true"
        android:theme="@style/My.Theme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

我的活动是做以下事情:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

在哪里R.layout.window_title_main:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_title"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:paddingLeft="5dp" >

    <TextView
        android:id="@+id/textview_title"
        android:drawableLeft="@null"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="-1"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

当它似乎适合其他人时,为什么这不起作用?

android

2
推荐指数
1
解决办法
5964
查看次数