6

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
Tushar Gogna
  • 4,963
  • 6
  • 31
  • 42
SHAKTHI VELAN
  • 133
  • 1
  • 7

1 Answers1

11

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>
Andrei Anhurets
  • 143
  • 1
  • 13
David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • ..Please refer the [link](http://www.edumobile.org/android/android-programming-tutorials/creating-a-custom-title-bar/) .. my code like this. can you tell me how can i change theme ** Theme.AppCompat.Light ** – SHAKTHI VELAN Dec 11 '14 at 08:14
  • If you aren't using the action bar, just replace `parent="AppTheme.Base"` with `parent="android:Theme"` in your `style` declaration for `AppTheme`. – David Wasser Dec 11 '14 at 11:07
  • I have changed but it showing same as previous design theme it doesn't show the Light version theme like white color alert backgrounds. – SHAKTHI VELAN Dec 12 '14 at 07:04
  • I added a suggestion to my answer. Try that. – David Wasser Dec 12 '14 at 10:27
  • Do you need to use the compatibility library for this? What version of Android do you need to support? – David Wasser Dec 12 '14 at 10:27
  • Yes, I have added compatibility library new appcompact-V7 in my project to work on android API version 7 to Update version 21, all API support same light version theme, all version themes works on material theme. – SHAKTHI VELAN Dec 12 '14 at 12:10
  • Did you try my suggestion? Does this solve your problem? – David Wasser Dec 12 '14 at 14:04
  • I'm tried but still not solve this problem, i have the same error while compiling the update theme. – SHAKTHI VELAN Dec 15 '14 at 05:42
  • What changes did you end up making? – David Wasser Dec 15 '14 at 15:17
  • I have used the two different theme like starting application run one theme and all activity runs on another theme, I,m modified the activity theme its working correctly.and also previously im used the _ – SHAKTHI VELAN Dec 16 '14 at 05:15
  • @DavidWasser http://stackoverflow.com/questions/31157222/how-to-change-action-bar-background-and-text-colors – Aditya Jul 01 '15 at 09:21