Android Studio 0.4.5
用于创建自定义对话框的Android文档:http://developer.android.com/guide/topics/ui/dialogs.html
如果需要自定义对话框,则可以将"活动"显示为对话框,而不是使用"对话框API".只需创建一个活动并将其主题设置为<activity>清单元素中的Theme.Holo.Dialog :
<activity android:theme="@android:style/Theme.Holo.Dialog" >
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这个时,我得到以下异常:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
Run Code Online (Sandbox Code Playgroud)
我支持以下内容,我不能使用大于10的内容:
minSdkVersion 10
targetSdkVersion 19
Run Code Online (Sandbox Code Playgroud)
在我的风格中,我有以下内容:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)
在我的清单中,我有这个活动:
<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>
Run Code Online (Sandbox Code Playgroud)
像我这样创建对话框是我要做的事情,因为我已经完成了布局.
谁能告诉我如何解决这个问题?
试图移动我的东西Toolbar而不是动作栏,但我不断收到错误说
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. …Run Code Online (Sandbox Code Playgroud) android android-actionbar material-design android-5.0-lollipop android-toolbar
我刚刚升级了我的应用程序以使用新发布的v22.1.0 AppCompat,当我打开我的应用程序时,我现在收到以下异常.
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
Run Code Online (Sandbox Code Playgroud)
我如何解决它?
所以我正在查看 google 的操作栏 api 演示,他们有这个
// The Action Bar is a window feature. The feature must be requested
// before setting a content view. Normally this is set automatically
// by your Activity's theme in your manifest. The provided system
// theme Theme.WithActionBar enables this for you. Use it as you would
// use Theme.NoTitleBar. You can add an Action Bar to your own themes
// by adding the element <item name="android:windowActionBar">true</item>
// to your style definition.
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试添加最后一行代码时,getWindow().requestFeature(Window.FEATURE_ACTION_BAR); …
android ×4