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