在android开发中界面使用到checkbox这个控件的时候遇到了文章标题的错误,百度google都查不到我想要的答案.
我的代码没有问题,就是一个checkbox控件,然后在activity中实例化并使用它的监听器,在4.4的版本中运行出现闪退,而在5.0的版本中就可以完美运行,真是个奇怪的错误.
最后通过查看官方文档发现,在控件这一节,有个声明
You can control exactly how your controls are styled using a theme that you apply to your entire application. For instance, to ensure that all devices running Android 4.0 and higher use the Holo theme in your app, declare android:theme="@android:style/Theme.Holo" in your manifest's <application> element.
大致的意思就是,你可以控制你的控件使用什么主题,那估计是主题不兼容的问题,用文中提到的android:theme=”@android:style/Theme.Holo”
主题将manifest中系统默认生成的主题替换掉,果然可以在4.4的版本中运行了.
如果大家遇到的也是这个问题,那不妨试试这个方法,