package my.surface;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class SurfaceActivity extends Activity {
SurfaceActivity.MyCallBack myCallBacks = new MyCallBack();
SurfaceView sView = null; //Create an abstract view which can display something later.
SurfaceHolder sHolder = null;//with holder to do actual painting
//This class is created for actual behaviors when meets following status :surface create , destroy and change
private class MyCallBack implements SurfaceHolder.Callback{
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
public void surfaceCreated(SurfaceHolder holder) {
Canvas canvas = holder.lockCanvas();
canvas.drawColor(Color.GREEN);
holder.unlockCanvasAndPost(canvas);
}
public void surfaceDestroyed(SurfaceHolder holder) {
}
}
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
sView = new SurfaceView(this);//This activity is treated as a context for the surface view.
sHolder = sView.getHolder();//get a holder from this view to do control.
sHolder.addCallback(myCallBacks);
setContentView(sView);
}
}
網頁
BloggerAds 廣告
標籤
- Java (96)
- Android (27)
- 演算法 (21)
- c++ (19)
- JavaScript (7)
- OpenMp (6)
- Design Pattern (4)
- 日文歌曲 (4)
- 資料結構 (4)
- Foundation Knowledge Of Programming (3)
- QUT (2)
- CodingHomeWork (1)
- Database (1)
- 英文歌詞 (1)
搜尋此網誌
2012年6月1日 星期五
Surface View example
訂閱:
張貼留言 (Atom)
我的網誌清單
標籤
日文歌曲
(4)
股市
(7)
股票
(9)
英文歌詞
(1)
時事
(1)
硬體(hardware)
(1)
資料結構
(4)
演算法
(21)
數學(Math)
(4)
ACM
(3)
ajax
(7)
algorithms
(1)
Android
(27)
Blog Notes(部落格記事)
(6)
C
(9)
c++
(19)
CodingHomeWork
(1)
Database
(1)
Design Pattern
(4)
Foundation Knowledge Of Programming
(3)
GWT
(1)
How
(2)
J2EE
(1)
Java
(96)
Java語言
(4)
JavaScript
(7)
Leetcode
(4)
LOL
(1)
OpenMp
(6)
QUT
(2)
Uva
(2)
Yahoo知識問答
(11)
沒有留言:
張貼留言