今天继续读郭少的<<第一行代码>>,在研究2.4.4体验活动的生命周期,根据书上代码重新敲了一遍,在点击Start DialoyActivity按钮时,程序后台报错,如下:
/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.activityliftcycletest, PID: 4503
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.activityliftcycletest/com.example.activityliftcycletest.DialogActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:355)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:324)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:285)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.activityliftcycletest.DialogActivity.onCreate(DialogActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.
我在AndroidManifest.xml中写的是:
<activity android:name=".DialogActivity"
android:theme="@android:style/Theme.Dialog">
</activity>
根据提示,告诉我下面这句话有问题
android:theme="@android:style/Theme.Dialog"
解决方案有2:
1、将DialogActivity继承类由AppCompatActivity改为Activity
2、将android:theme="@android:style/Theme.Dialog"改为
android:theme="@style/Theme.AppCompat.Dialog"
相关推荐
* 如果继承自 AppCompatActivity,将会报错,例如:java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity。 解决方法是将 Activity 继承自 Activity,...
在采用透明主题时,可能会遇到不兼容的问题,如"java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity."。这通常是因为Activity继承自AppCompatActivity...
Please keep in mind that this book is intended to show you a few useful techniques and inspire you to achieve good things. Please strive to understand your network and what you need to do to make it...
- **`serialize(formElement[, getHash=false])`**: Serializes a form into a URL-encoded string for use in an AJAX request. - **`serializeElements(elements[, getHash=false])`**: Serializes a collection ...
TRxQuery is a TQuery descendant. It supports macros in the SQL text, which are similar to Params. Macros allow to change query text easily and handy. TSQLScript allows multiple SQL statements in one ...
TRxQuery is a TQuery descendant. It supports macros in the SQL text, which are similar to Params. Macros allow to change query text easily and handy. TSQLScript allows multiple SQL statements in one ...
2. 层次选择器:`后代选择器(ancestor descendant)、子元素选择器(parent > child)、相邻兄弟选择器(+ element)、后续兄弟选择器(~ element)`。 3. 特性选择器:`[attribute]、[attribute=value]、[attribute^=...
SQLMemTable for Delphi / C++ Builder: README============================================Please read this file carefully (especially the INSTALLATION chapter) before installing the program to your ...
- 例句:A vigorous exercise routine improves overall health. 41. **productive** [prE5dQktIv] *a.* 多产的;富饶的 - 例句:Productive farms produce large amounts of crops each season. 42. **fancy** ...
- **例句**:“He is the offspring of a famous writer.” 更加文雅的说法是 “He is a descendant of a renowned author.” #### 4. inevitable -> dispensable - **注意**:这里的“dispensable”似乎与...
- creating a descendant compiled product such as OCX or ActiveX control and sell or distribute this as a product - using the control in applications sold with different publisher name than the ...
These Internet components give you everything you need to jumpstart your Internet development without any external dependencies. The suite of Internet Components contain over fifty components which ...
1. 后代选择器(`ancestor descendant`):选择祖先元素内的后代元素。 2. 子元素选择器(`parent > child`):选择父元素的直接子元素。 3. 相邻兄弟选择器(`element + element`):选择紧接在另一个元素后的元素...
vue-removed-hook-mixin 向组件添加一个removed... // this.$el is no longer a descendant of document.body. } } // 2) Apply the mixin to all components. import addRemovedHook from "vue-removed-hook-mixi
在Android开发中,焦点管理是构建用户界面时一个至关重要的部分。`DescendantFocusability`是Android布局中处理子视图焦点转移的一个属性,它决定了一个父布局如何处理其子视图之间的焦点移动。这个属性主要用在如`...
WordPress is a blog publishing system written in the PHP programming language and using a MySQL database. WordPress is the official descendant of b2 / cafelog
DIZipWriter outputs all data to the archive straight away, with no need for temporary storage: It does not create any temporary files and does not use huge amount of memory for buffering. It is ...
Returning 'true' from within the loop skips to the next iteration (this is like using a 'continue' with a normal loop). 返回值 jQuery 参数 callback (Function) : 对于每个匹配的元素所要执行的函数 ...
Also, a new design for the User Administration Module with more features and easier to use. The new Automatic Audit feature allows the developer to trace any changes in the datasets (deleted records,...
2. **层级选择器**:`$("ancestor descendant")`选取祖先元素下的子孙元素,`$("parent > child")`选取父元素直接的子元素,`$("prev + next")`选取紧接在前一个元素后面的元素,`$("prev ~ siblings")`选取前一个...