I have the following code:
LayoutInflater factory = LayoutInflater.from(this);
View view_with_buttons_on = factory.inflate(R.layout.buts, null);
view_with_buttons_on.setBackgroundColor(Color.TRANSPARENT);
game_frame_layout = new FrameLayout(getApplicationContext());
surface_view_extension = new SurfaceViewExtension(getApplicationContext());
game_frame_layout.addView(surface_view_extension);
game_frame_layout.addView(view_with_buttons_on);
setContentView(game_frame_layout);
preview_texture_view = (TextureView) findViewById(R.id.tex1);
try {
camera.setPreviewTexture(preview_texture_view.getSurfaceTexture());
} catch (IOException e) {
e.printStackTrace();
}
The buts.xml layout contains a set of buttons as well as TextureViewa tag "@id/tex1". It seems to preview_texture_view.getSurfaceTexture()return null. The documentation states:
This method can return null if the view is not bound to the window or if the surface texture has not yet been initialized.
I assume that the surface should already be attached to the window because the buttons are visible, so I assume that my error should not be initialized by preview_texture_view, but I have no idea what it means to βinitializeβ preview_texture_view, except that I have already done. I saw some related code example and can't figure out any initialization process.
: , , . , , ?.. .