2011-06-01 47 views
0

我目前正在运行下面的堆栈输出,因为它会抛出一个错误。从dip转换到px

Resources r = getResources(); 
    float pix = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, r.getDisplayMetrics()); 

> Uncaught handler: thread main exiting due to uncaught exception 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.pne/com.test.pne.one}: android.content.res.Resources$NotFoundException: String resource ID #0xe 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 
at android.app.ActivityThread.access$2100(ActivityThread.java:116) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:4203) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:521) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0xe 
at android.content.res.Resources.getText(Resources.java:205) 
at android.widget.TextView.setText(TextView.java:2809) 
at com.quiz.max.Quiz.onCreate(Quiz.java:87) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 
... 11 more 

回答

0

我甚至不真正看到你的问题是什么,但错误好像它是由一个没有被找到字符串资源造成的(也许尝试修复Android项目的属性?)

Caused by: android.content.res.Resources$NotFoundException: String resource ID #0xe at 

也许如果你解释更多你想要的,我可以尝试帮助更多。

+0

即时尝试将14 dip转换为其相对像素值。 – Somk 2011-06-01 21:39:01

+1

这是因为我试图将text设置为一个不是字符串的整数。谢谢你指出。 – Somk 2011-06-01 21:47:30