You need to use a Theme.AppCompat theme (or descendant) with this activity.
来源:互联网 发布:mysql数据库锁表原因 编辑:程序博客网 时间:2024/06/16 19:46
今天代码在 builder.show()出报出 You need to use a Theme.AppCompat theme (or descendant) with this activity.
通过看源码分析最后将
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
改为
AlertDialog.Builder builder = new AlertDialog.Builder(activity,R.style.Theme_AppCompat_Light_Dialog_Alert);
解决。
查询网上结果发现
方法1:(此方法问题未解决)
创建的activity时,如果不是那么强烈需要继承自AppCompatActivity,就直接继承Activity。
如将activity继承自AppCompatActivity:
public class MainActivity extends ActionBarActivity
改成activity继承自Activity:
我的Activity继承 android.support.v4.app.FragmentActivity,直接继承Activity后问题依然存在。
方法2:(此方法解决问题)
还是想继承自AppCompatActivity,那么根据提示来使用AppCompat的theme,即将AndroidManifest.xml文件中关于Activity的主题配置改成:
android:theme=”@style/Theme.AppCompat.Light.NoActionBar”</code>
完整代码如下:
<activity android:name=”.module.view.activity.KuwoMusicPlayActivity”
android:theme=”@style/Theme.AppCompat.Light.NoActionBar”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
这个方法可以解决问题。
通过看源码分析最后将
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
改为
AlertDialog.Builder builder = new AlertDialog.Builder(activity,R.style.Theme_AppCompat_Light_Dialog_Alert);
解决。
查询网上结果发现
方法1:(此方法问题未解决)
创建的activity时,如果不是那么强烈需要继承自AppCompatActivity,就直接继承Activity。
如将activity继承自AppCompatActivity:
public class MainActivity extends ActionBarActivity
改成activity继承自Activity:
我的Activity继承 android.support.v4.app.FragmentActivity,直接继承Activity后问题依然存在。
方法2:(此方法解决问题)
还是想继承自AppCompatActivity,那么根据提示来使用AppCompat的theme,即将AndroidManifest.xml文件中关于Activity的主题配置改成:
android:theme=”@style/Theme.AppCompat.Light.NoActionBar”</code>
完整代码如下:
<activity android:name=”.module.view.activity.KuwoMusicPlayActivity”
android:theme=”@style/Theme.AppCompat.Light.NoActionBar”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
这个方法可以解决问题。
转自:http://blog.csdn.net/jyw935478490/article/details/72868751
阅读全文
0 0
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- Android开发~you need to use a theme.appcompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- 【Android】You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决
- you need to use a theme.appcompat theme (or descendant) with this activity 解决办法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 报错 You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android Studio You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- 关于You need to use a Theme.AppCompat theme (or descendant) with this activity的问题
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- POJ 3347 Kadj Squares <几何>
- MySQL5.7 GTID在线开启与关闭
- hcash超级现金公布区块链中量子密码测试版将于近期问世
- hdu2544-最短路径spaf
- SEO快排服务:快速上首页的背后
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- TankWar游戏(图片版)----阶段八
- xliview多布局
- 这是我第一天来准备写博客。
- 九九乘法
- LeetCode题解 第九周
- tf.transpose (API r1.3)
- 归纳一下C语言
- ReTrofit请求post