3

Switchをトグルとして使用するアプリをコーディングしました。ICSで実行すると問題はありませんが、ジンジャーブレッドで実行するとクラッシュします。

05-04 11:00:43.261: E/AndroidRuntime(1455): FATAL EXCEPTION: main
05-04 11:00:43.261: E/AndroidRuntime(1455): java.lang.RuntimeException: Unable to start activity ComponentInfo{it.android.smartscreenon/it.android.smartscreenon.ActivityImpostazioni}: android.view.InflateException: Binary XML file line #58: Error inflating class Switch
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.os.Looper.loop(Looper.java:130)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread.main(ActivityThread.java:3835)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at java.lang.reflect.Method.invokeNative(Native Method)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at java.lang.reflect.Method.invoke(Method.java:507)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at dalvik.system.NativeStart.main(Native Method)
05-04 11:00:43.261: E/AndroidRuntime(1455): Caused by: android.view.InflateException: Binary XML file line #58: Error inflating class Switch
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.Activity.setContentView(Activity.java:1657)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at it.android.smartscreenon.ActivityImpostazioni.onCreate(ActivityImpostazioni.java:43)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
05-04 11:00:43.261: E/AndroidRuntime(1455):     ... 11 more
05-04 11:00:43.261: E/AndroidRuntime(1455): Caused by: java.lang.ClassNotFoundException: android.view.Switch in loader dalvik.system.PathClassLoader[/data/app/it.android.smartscreenon-1.apk]
05-04 11:00:43.261: E/AndroidRuntime(1455):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
05-04 11:00:43.261: E/AndroidRuntime(1455):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
05-04 11:00:43.261: E/AndroidRuntime(1455):     ... 23 more

SwitchはGingerbreadに存在しないようです。どうすれば問題を解決できますか?

4

1 に答える 1

1

代わりにトグルボタンを使用してください。スイッチは API レベル 14 で追加されました。ドキュメントは次のとおりです。

于 2012-12-28T08:59:25.957 に答える