Skip to content Skip to sidebar Skip to footer

Android:crash: Binary Xml File Line : Error Inflating Class (using Surfaceview)

I'm having android surfaceView and in that I'm trying to add buttons to this. In the surfaceView canvas I draw something. And I have a thread class to keep drawing. package com.and

Solution 1:

First, you must declare your view as a static type, to be able to be inflated it even when no instance of the holding class is available:

publicstaticclassMySurfaceViewextendsSurfaceViewimplementsSurfaceHolder.Callback

The line

<com.androidsurfaceview.test.MySurfaceView

in your layout xml suggests, that the MySurfaceView class is inside the com.androidsurfaceview.test package, and tries to inflate it from there, which is wrong.

In your layout you should follow the package.class$innerclass form of declaration.

BUT since the "$" is illegal character, you cannot write

<com.androidsurfaceview.test$MySurfaceView

so you must specify your view in the layout xml as follows:

<view class="com.androidsurfaceview.test$MySurfaceView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

This way it will work.

Post a Comment for "Android:crash: Binary Xml File Line : Error Inflating Class (using Surfaceview)"