Reputation: 75975
I'm trying to use the SurfaceView widget. I have a class
public class OurView extends SurfaceView implements Runnable {
public OurView(Context context) {
super(context);
Log.d("OurView", "Yay We started");
}
@Override
public void run() {
}
}
So I have a SurfaceView widget in my Activity's XML. I then try to bind it in the onCreate
method
TheView = (OurView) findViewById(R.id.theSurfaceView);
The problem is here I get an error that I can't cast OurView
to android.view.SurfaceView
.
I know usually I could just do this to the view itself, in the onCreateMethod
TheView = new OurView(this);
setContentView(TheView);
The thing is I don't want to do this, I don't want to draw on my whole activity I just want to draw on the SurfaceView widget that i've put on the layout. How would I do that?
Upvotes: 1
Views: 884
Reputation: 12160
You should put your customized SurfaceView com.xx.OurView
in your layout, not SurfaceView
.
Upvotes: 3