Render View : View « UI « Android






Render View

    
package app.test;

import java.util.Random;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class Test extends Activity {
  class RenderView extends View {
    Random rand = new Random();

    public RenderView(Context context) {
      super(context);
    }

    protected void onDraw(Canvas canvas) {
      canvas.drawRGB(rand.nextInt(256), rand.nextInt(256),
          rand.nextInt(256));
      invalidate();
    }
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(new RenderView(this));
  }
}

   
    
    
    
  








Related examples in the same category

1.Brightness Slider
2.extends View to do drawing
3.Set View background
4.Extends View to draw
5.extends View to create customized User interface widget
6.Using Reflection to call method
7.Example of how to write a custom subclass of View.
8.Demonstrates making a view VISIBLE, INVISIBLE and GONE
9.Pint View
10.Compass View
11.Bars View
12.Graph View
13.View inflate