gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:58:08 24 4
gpt4 key购买 nike

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

样式代码

 <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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com