android - You need to use a Theme.AppCompat theme (or descendant) with this activity -


android studio 0.4.5

android documentation creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html

if want custom dialog, can instead display activity dialog instead of using dialog apis. create activity , set theme theme.holo.dialog in <activity> manifest element:

<activity android:theme="@android:style/theme.holo.dialog" > 

however, when tried following exception:

java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity 

i supporting following, , can't using greater 10 min:

minsdkversion 10 targetsdkversion 19 

in styles have following:

<!-- base application theme. -->     <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> 

and in manifest have activity:

 <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:theme="@android:style/theme.holo.light.dialog"             android:name="com.ssd.register.dialog_update"             android:label="@string/title_activity_dialog_update" >         </activity> 

creating dialog box hopping do, have completed layout.

can tell me how can around problem?

the reason having problem because activity trying apply dialog theme extending actionbaractivity requires appcompat theme applied.

update: extending appcompatactivity have problem

in case, change java inheritance actionbaractivity activity , leave dialog theme in manifest is, non theme.appcompat value


the general rule if want code support older versions of android, should have appcompat theme , java code should extend appcompatactivity. if have *an activity doesn't need support, such care latest versions , features of android, can apply theme java code must extend plain old activity.


note: when change appcompatactivity (or subclass, actionbaractivity), activity, must change various calls "support" corresponding call without "support". so, instead of getsupportfragmentmanager, call getfragmentmanager.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -