私はlogcatでこの奇妙なエラーが発生していると私はそれを解決し、それを得るために私の心に来たすべてを試してみました。ここ はlogcatです:android.view.InflateException:バイナリXMLファイル
11-08 12:30:26.184: E/AndroidRuntime(4396): FATAL EXCEPTION: main
11-08 12:30:26.184: E/AndroidRuntime(4396): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dm.test/com.dm.test.ui.BitCanvasActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class com.dm.test.ui.BitCanvasActivity$CanvasView
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1696)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.os.Looper.loop(Looper.java:123)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread.main(ActivityThread.java:3806)
11-08 12:30:26.184: E/AndroidRuntime(4396): at java.lang.reflect.Method.invokeNative(Native Method)
11-08 12:30:26.184: E/AndroidRuntime(4396): at java.lang.reflect.Method.invoke(Method.java:507)
11-08 12:30:26.184: E/AndroidRuntime(4396): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-08 12:30:26.184: E/AndroidRuntime(4396): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-08 12:30:26.184: E/AndroidRuntime(4396): at dalvik.system.NativeStart.main(Native Method)
11-08 12:30:26.184: E/AndroidRuntime(4396): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class com.dm.test.ui.BitCanvasActivity$CanvasView
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.createView(LayoutInflater.java:508)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-08 12:30:26.184: E/AndroidRuntime(4396): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.Activity.setContentView(Activity.java:1716)
11-08 12:30:26.184: E/AndroidRuntime(4396): at com.dm.test.ui.BitCanvasActivity.onCreate(BitCanvasActivity.java:55)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)
11-08 12:30:26.184: E/AndroidRuntime(4396): ... 11 more
11-08 12:30:26.184: E/AndroidRuntime(4396): Caused by: java.lang.NoSuchMethodException: CanvasView(Context,AttributeSet)
11-08 12:30:26.184: E/AndroidRuntime(4396): at java.lang.Class.getMatchingConstructor(Class.java:643)
11-08 12:30:26.184: E/AndroidRuntime(4396): at java.lang.Class.getConstructor(Class.java:472)
11-08 12:30:26.184: E/AndroidRuntime(4396): at android.view.LayoutInflater.createView(LayoutInflater.java:480)
11-08 12:30:26.184: E/AndroidRuntime(4396): ... 21 more
、これが私のxmlです:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bitdraw="http://schemas.android.com/apk/res/com.dm.test" >
<view
class="com.dm.test.ui.BitCanvasActivity$CanvasView"
android:id="@+id/backgroundz"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.dm.test.widget.ActionButtons
android:id="@+id/btn_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="135dp"
android:layout_gravity="bottom|center_horizontal" />
<com.dm.test.widget.ColorPicker
android:id="@+id/color_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:orientation="horizontal"
bitdraw:colors="@array/color_picker_colors"
bitdraw:cols="3"
bitdraw:fils="5" />
</merge>
との.javaライン55上のその本:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bit_canvas); //line 55
mActionButtons = (ActionButtons) findViewById(R.id.btn_actions);
mColorPicker = (ColorPicker) findViewById(R.id.color_picker);
、これは、内側の一部でありますクラス:
S
内部クラスstaticを宣言する必要があります。 この[stackoverflowの上の回答] [1] を参照してください[1]:http://stackoverflow.com/questions/4483433/error-inflating-inner-class-view –