Example usage for android.view SurfaceView setOnClickListener

List of usage examples for android.view SurfaceView setOnClickListener

Introduction

In this page you can find the example usage for android.view SurfaceView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.chrulri.droidoflife.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  www.j  av a2s.c  o  m
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    settingsCache = SettingsActivity.loadSettings(this);

    SurfaceView view = (SurfaceView) findViewById(R.id.main_surfaceView);
    surface = view.getHolder();

    restartRuntime();

    view.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable iteration task for manual mode
            if (iterationTask != null) {
                iterationTask.cancel(false);
                iterationTask = null;
            } else {
                doIteration();
            }
            refreshTitle();
        }
    });
    surface.addCallback(new SurfaceHolder.Callback() {
        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            doRender();
        }

        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            doRender();
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            // ignore
        }

    });

    refreshTitle();

    // Manual
    // TODO show manual
}