I am new to Android, so please excuse me if it is set earlier!
I play with some camera code (found on the Internet) and I want to show / hide some buttons on the screen. When the user touches the screen, I want him to capture the image.
My setup:
1. Main activity:
public class CameraDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_inuse);
preview = new Preview(this);
((FrameLayout) findViewById(R.id.preview)).addView(preview);
... ...
}
2. The preview class is as follows:
class Preview extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder;
public Camera camera;
Preview(Context context) {
super(context);
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
My question is:
How can I add touch functionality so that the user can touch the preview (say, for a second or just quickly click) and something happens? (Say the image is saved)
And the "Next" button will appear on the surface, for example?
source
share