我想让用户可以通过首选项中的 ListPreference 在我的应用程序中更改我的文本的 textSize。我怎样才能做到?
它尝试了一个字符串变量,但是当我写例如 25sp 时出现了一个异常 .. 那里有什么问题?
这是一个例外:
04-07 09:02:20.475: ERROR/AndroidRuntime(287): android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at de.mprengemann.hwr.timetabel.SubjectListView$SubjectAdapter.getView(SubjectListView.java:881)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.ListView.makeAndAddView(ListView.java:1727)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.ListView.fillDown(ListView.java:652)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.ListView.fillFromTop(ListView.java:709)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.ListView.layoutChildren(ListView.java:1580)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.View.layout(View.java:7035)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.TableLayout.onLayout(TableLayout.java:437)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.View.layout(View.java:7035)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.View.layout(View.java:7035)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.View.layout(View.java:7035)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.View.layout(View.java:7035)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.os.Looper.loop(Looper.java:123)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at java.lang.reflect.Method.invoke(Method.java:521)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at dalvik.system.NativeStart.main(Native Method)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): Caused by: java.lang.reflect.InvocationTargetException
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.TextView.<init>(TextView.java:321)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at java.lang.reflect.Constructor.constructNative(Native Method)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): ... 38 more
04-07 09:02:20.475: ERROR/AndroidRuntime(287): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): at android.widget.TextView.<init>(TextView.java:640)
04-07 09:02:20.475: ERROR/AndroidRuntime(287): ... 42 more
非常感谢 :)