android custom view not inflating
NickName:Jonathan Vukadinovic Ask DateTime:2015-11-16T07:16:06

android custom view not inflating

I made a custom view that extends the View class:

 import android.content.Context;
 import android.graphics.Canvas;
 import android.view.View;

 public class DrawSurfaceView extends View
 {

private ButtonsManager BM;
public DrawSurfaceView(Context context) {
    super(context);

}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    BM.draw(canvas);
}


}

I included it in the xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
 >

        <TextureView
        android:id="@+id/gameSurface"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

                    <com.example.trashedometer.DrawSurfaceView
                android:id="@+id/drawingSurface"
                android:layout_width="match_parent"
                android:layout_height="match_parent" 
                />

</FrameLayout>

But in the main code when it sets the content view it says it can't inflate my custom view, why?

 setContentView(R.layout.activity_main);

Copyright Notice:Content Author:「Jonathan Vukadinovic」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/33726279/android-custom-view-not-inflating

More about “android custom view not inflating” related questions

Custom View in Android not Inflating

Below is my code for Custom View. I am basically creating a circle and putting some text into it. Even though i have overloaded both constructors i get the layout not inflated error. package com.e...

Show Detail

Android - Error when inflating custom View in XML

I have a custom view but I'm unable to use it because something related to namespaces that causing an Exception: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.pc.

Show Detail

Custom View not inflating

I am trying to create my custom view through xml, but the screen does not show my view, s it is not inflating. My custom view xml is as: &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ViewSw...

Show Detail

Custom View children are null after inflating the view in Android

I am working on an Android app. I have a custom view and layout as follows: &lt;com.hello.view.card.inner.SimpleCardView xmlns:android="http://schemas.android.com/apk/res/android" android:...

Show Detail

StackOverflowError when inflating custom view which contains its own views

I am having a Fragment, where I inflate "fragment_board.xml": &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

Show Detail

Inflating a custom control in Android

In my activity I have a custom made control. In onCreate I inflate the activity's view as normal with: setContentView(R.layout.image_viewer); Here is my xml: &lt;?xml version="1.0" encoding="utf...

Show Detail

Inflating a view with custom locale in Android

I'm using a LayoutInflater to inflate a custom layout to generate invoices and receipts as Bitmaps then I send them to the printer or export them as png files, Like this: LayoutInflater inflater =

Show Detail

Error inflating custom view class in xml in Android Studio

I'm using Android Studio 1.0 RC 1 and I'm having trouble inflating a view class in xml file. I have a view file which extends GridView and which contains all 3 constructors: package app.views; i...

Show Detail

android custom view not inflating

I made a custom view that extends the View class: import android.content.Context; import android.graphics.Canvas; import android.view.View; public class DrawSurfaceView extends View { private

Show Detail

Android inflating custom view in XML ClassNotFound error

I have some problems with my XML code i hope you can help me with. I have this class in this package: package com.example.myview public class CustomDialog extends DialogPreference { public

Show Detail