开发者

Android theme declaration

开发者 https://www.devze.com 2023-04-09 07:27 出处:网络
I have a problem. I created new app and publish it to market, but most part of users get ANR with Caused by: java.lang.reflect.InvocationTargetException

I have a problem. I created new app and publish it to market, but most part of users get ANR with

Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505) ... 39 more Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010019 a=-1} at android.content.res.Resources.loadDrawable(Resources.java:1699) at android.content.res.TypedArray.getDrawable(TypedArray.java:601) at android.view.View.(View.java:1998) at android.view.View.(View.java:1946) at android.view.ViewGroup.(ViewGroup.java:304) at android.widget.RelativeLayout.(RelativeLayout.java:173) ... 42 more

In my app I have a two themes that declared in themes.xml. I think I have a mistake in theme declaration. How properly define themes in styles? What difference between

 <style name="DarkTheme" parent="android:Theme.Black.NoTitleBar">

and

<style name="开发者_JAVA百科DarkTheme" parent="@android:style/Theme.NoTitleBar">


    <style name="DarkTheme" parent="@android:style/Theme.NoTitleBar">

That theme declaration is correct. The @android tells your software to look inside the Android package for resources. :style means that inside the android package it should look at the styles of that package for the style named after the /.


I'm using something similar to the first way of defining the theme parent, i.e.:

<style name="DarkTheme" parent="android:Theme.Black.NoTitleBar">

It works just fine for me. Perhaps try only using that. I've tried both ways and they seemed to work though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号