Android Open Source - Canvas-Test Main Canvas Activity






From Project

Back to project page Canvas-Test.

License

The source code is released under:

Apache License

If you think the Android project Canvas-Test listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package foobar.canvastest;
/* w  w  w . j a  v a  2 s.com*/
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import foobar.canvastest.drawing.scenes.ExampleScene;

/**
 * This is the main "Activity", the Android equivalent of a page or form.
 * 
 * Its UI corresponds to what is given in res/layout/main.xml
 * One of the elements, the actual MySurfaceView we draw on, is created
 * programatically as opposed to being in the xml. This is because it is a
 * custom class without any XML binding
 */
public class MainCanvasActivity extends Activity {
  MySurfaceView mSurfaceView;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ViewGroup containerView = (ViewGroup)findViewById(R.id.containerView);
    mSurfaceView = new MySurfaceView(this, new ExampleScene());

    containerView.addView(mSurfaceView);
  }
}




Java Source Code List

foobar.canvastest.MainCanvasActivity.java
foobar.canvastest.MySurfaceView.java
foobar.canvastest.drawing.Drawable.java
foobar.canvastest.drawing.scenes.ExampleScene.java