草庐IT

android.util.AndroidRuntimeException : You cannot combine custom titles with other title features

coder 2023-12-19 原文

您好,我的代码出现错误。你能告诉我如何解决这个问题吗?

样式代码

 <style name="AppTheme" parent="AppTheme.Base"/>
 <style name="AppTheme.Base" parent="Theme.AppCompat.Light">

Activity 代码

@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);

list 代码

<activity android:name=".CreateAccountActivity1" 
          android:theme="@style/AppTheme"/>

** 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"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:clickable="true"
                    android:onClick="whatsThisClick"
                    android:text="@string/what_this"
                    android:visibility="gone" />


        <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

        <ScrollView            
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"  >

            <LinearLayout
                android:layout_height="wrap_content"
                android:layout_width="280sp"
                android:paddingTop="5sp"
                android:gravity="center_horizontal"
                android:layout_gravity="center_horizontal"
                android:orientation="vertical" >


                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text="@string/user_name"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black"
                    android:textAppearance="?android:attr/textAppearanceMedium" 
                    android:layout_marginTop="5dp"/>
                <EditText
                    android:id="@+id/user_name"
                    android:layout_width="fill_parent"
                    android:textSize="@dimen/default_size"
                    android:singleLine="true"
                    android:inputType="textEmailAddress"
                    android:layout_marginTop="4dp" 
                    android:layout_height="40dp"
                    android:background="@drawable/rouned_corner"
                    android:paddingLeft="5dp" >
                    <requestFocus />
                </EditText>
                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text="@string/dob"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:layout_marginTop="5dp"  />
                <EditText
                    android:id="@+id/dobText"
                    android:layout_width="fill_parent"
                    android:textSize="@dimen/default_size"
                    android:singleLine="true"
                    android:inputType="date"
                    android:hint="@string/dateMMDDYYYY"
                    android:maxLength="10"
                    android:clickable="false"
                    android:focusable="true"
                    android:layout_marginTop="4dp" 
                    android:layout_height="40dp"
                    android:background="@drawable/rouned_corner"
                    android:paddingLeft="5dp" > <!-- android:onClick="onDobTextClick" -->
                </EditText>
                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text="@string/password"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:layout_marginTop="5dp"  />
                <EditText
                    android:id="@+id/password"
                    android:layout_width="fill_parent"
                    android:textSize="@dimen/default_size"
                    android:singleLine="true"
                    android:inputType="number"
                    android:maxLength="4"
                    android:layout_marginTop="4dp" 
                    android:layout_height="40dp"
                    android:background="@drawable/rouned_corner"
                    android:paddingLeft="5dp" >
                </EditText>
                <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:text="@string/conform_password"
                    android:textSize="@dimen/default_size"
                    android:textColor="@color/black"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:layout_marginTop="5dp" />
                <EditText
                    android:id="@+id/conform_password"
                    android:layout_width="fill_parent"
                    android:textSize="@dimen/default_size"
                    android:singleLine="true"
                    android:inputType="number"
                    android:maxLength="5"
                    android:layout_marginTop="4dp" 
                    android:layout_height="40dp"
                    android:background="@drawable/rouned_corner"
                    android:paddingLeft="5dp"
                    android:layout_marginBottom="20dp" >
                </EditText>



            </LinearLayout>



            </ScrollView>
            </LinearLayout>

        </LinearLayout>

     <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fafafa"
        android:orientation="vertical"
        android:gravity="bottom"    
        >
       <View
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:background="@android:color/black"  />

        <LinearLayout
            android:background="#fafafa"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="horizontal"        
            android:gravity="center"
            android:visibility="visible"    >

            <Button
                    android:id="@+id/submitBtn"
                    android:layout_width="100dp"
                    android:layout_height="40dp"
                    android:background="@drawable/button_bg"
                    android:onClick="next"
                    android:text="@string/next"
                    android:textColor="@color/white"
                    android:textSize="@dimen/default_size"
                    android:textStyle="bold" />



        </LinearLayout>

        </LinearLayout>

    </LinearLayout>

上面的代码是我的布局文件。

日志猫错误

    12-09 23:42:21.750: E/AndroidRuntime(10108): FATAL EXCEPTION: main
    12-09 23:42:21.750: E/AndroidRuntime(10108): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.velantech.activity/com.velantech.activity.ForgotUserIDActivity}: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.os.Handler.dispatchMessage(Handler.java:99)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.os.Looper.loop(Looper.java:137)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread.main(ActivityThread.java:4745)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at java.lang.reflect.Method.invokeNative(Native Method)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at java.lang.reflect.Method.invoke(Method.java:511)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at dalvik.system.NativeStart.main(Native Method)
    12-09 23:42:21.750: E/AndroidRuntime(10108): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:227)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2601)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2844)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.Activity.setContentView(Activity.java:1867)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at com.velantech.activity.ForgotUserIDActivity.onCreate(ForgotUserIDActivity.java:54)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.Activity.performCreate(Activity.java:5008)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
    12-09 23:42:21.750: E/AndroidRuntime(10108):    ... 11 more

最佳答案

您正在使用的主题 Theme.AppCompat.Light 包含此定义(在其父级中):

<item name="android:windowNoTitle">true</item>

所以主题说它没有标题,而您正尝试使用自定义标题。这是不兼容的。

您使用的主题包含操作栏,操作栏中的标题处理方式不同。参见 Styling the Action Bar.


编辑:没有操作栏的浅色主题的建议

要获得没有操作栏的“浅色”主题(这样您就可以使用自定义标题),这应该可行:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">false</item>
</style>

关于android.util.AndroidRuntimeException : You cannot combine custom titles with other title features,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27395263/

有关android.util.AndroidRuntimeException : You cannot combine custom titles with other title features的更多相关文章

  1. ruby - Facter::Util::Uptime:Module 的未定义方法 get_uptime (NoMethodError) - 2

    我正在尝试设置一个puppet节点,但ruby​​gems似乎不正常。如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它工作正常,但如果我通过由ruby​​gems(/usr/bin/facter)安装的二进制文件,它抛出:/usr/lib/ruby/1.8/facter/uptime.rb:11:undefinedmethod`get_uptime'forFacter::Util::Uptime:Module(NoMethodError)from/usr/lib/ruby

  2. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  3. ruby-on-rails - Ruby on Rails 教程 - 5.26 - Sublime Text "Unable to Save"新文件 "spec/support/utilities.rb" - 2

    我正在使用SublimeText2,同时遵循MichaelHartl的RubyonRails教程。可以在http://ruby.railstutorial.org/book/ruby-on-rails-tutorial找到我所指的教程的具体部分。(ctrl+F“list5.26”)。我能够创建规范/支持文件。但是,在尝试创建spec/support/utilities.rb文件时,我收到消息“无法保存~/rails_projects/sample_app/spec/support/utilities.rb”。有人知道为什么会这样吗?SublimeText论坛上有人似乎遇到了完全相同的问

  4. Android Studio开发之使用内容组件Content获取通讯信息讲解及实战(附源码 包括添加手机联系人和发短信) - 2

    运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid

  5. Android 10.0 设置默认launcher后安装另外launcher后默认Launcher失效的功能修复 - 2

    1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La

  6. AiBote 2022 新研发的自动化框架,支持 Android 和 Windows 系统。速度非常快 - 2

    Ai-Bot基于流行的Node.js和JavaScript语言的一款新自动化框架,支持Windows和Android自动化。1、Windowsxpath元素定位算法支持支持Windows应用、.NET、WPF、Qt、Java和Electron客户端程序和ie、edgechrome浏览器2、Android支持原生APP和H5界面,元素定位速度是appium十倍,无线远程自动化操作多台安卓设备3、基于opencv图色算法,支持找图和多点找色,1080*2340全分辨率找图50MS以内4、内置免费OCR人工智能技术,无限制获取图片文字和找字功能。5、框架协议开源,除官方node.jsSDK外,用户可

  7. Android Gradle 7.1+新版本依赖变化 - 2

    前一段时间由于工作需要把可爱的小雪狐舍弃了,找到了小蜜蜂。但是新版本的小蜜蜂出现了很多和旧版本不一样的位置。1.功能位置迁移,原来在工程build.gradle的buildscript和allprojects移动至setting.gradle并改名为pluginManagement和dependencyResolutionManagement。里面的东西依旧可以按照原来的copy过来。pluginManagement{repositories{gradlePluginPortal()google()mavenCentral()}}dependencyResolutionManagement{r

  8. ruby - Ruboto 的最佳教程(适用于 Android 的 ruby​​)? - 2

    关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于StackOverflow来说是偏离主题的,因为它们往往会吸引自以为是的答案和垃圾邮件。相反,describetheproblem以及迄今为止为解决该问题所做的工作。关闭9年前。Improvethisquestion我几乎用完了Ruby,但现在想试试Ruboto,android上的ruby​​。谷歌未能给我足够的(几乎没有结果)。所以任何人都可以分享一些关于Ruboto的教程。

  9. Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题 - 2

    Aproblemoccurredconfiguringrootproject'MyApplication2'.>Couldnotresolveallfilesforconfiguration':classpath'.  >Couldnotresolvecom.android.tools.build:gradle:7.4.2.   Requiredby:     project:>com.android.application:com.android.application.gradle.plugin:7.4.2     project:>com.android.library:com.andr

  10. Android对话框的详细介绍(提示对话框,自定义对话框) - 2

    简介:我们都知道在Android开发中,当我们的程序在与用户交互时,用户会得到一定的反馈,其中以对话框的形式的反馈还是比较常见的,接下来我们来介绍几种常见的对话框的基本使用。前置准备:(文章最后附有所有代码)我们首先先写一个简单的页面用于测试这几种Dialog(对话框)代码如下,比较简单,就不做解释了一、提示对话框(即最普通的对话框)首先我们给普通对话框的按钮设置一个点击事件,然后通过AlertDialog.Builder来构造一个对象,为什么不直接Dialog一个对象,是因为Dialog是一个基类,我们尽量要使用它的子类来进行实例化对象,在实例化对象的时候,需要将当前的上下文传过去,因为我这

随机推荐