Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Hi in my code getting error. Can you tell me how to fix the issue.

Style Code

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

Activity code

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

Manifest code

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

the above code is my layout file.

log-cat error

    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
like image 314
SHAKTHI VELAN Avatar asked Dec 10 '14 07:12

SHAKTHI VELAN


1 Answers

The theme you are using Theme.AppCompat.Light contains this definition (in its parent):

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

So the theme says that it has no title and you are tyring to use a custom title. This is incompatible.

The theme you are using contains an action bar, and the title in the action bar is handled differently. See Styling the Action Bar.


EDIT: Suggestion for light theme without action bar

To get a "light" theme without the action bar (so you can use custom title), this should work:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">false</item>
</style>
like image 123
David Wasser Avatar answered Nov 04 '22 22:11

David Wasser