WEB开发网
开发学院手机开发Android 开发 在Android层实现触摸屏校验 阅读

在Android层实现触摸屏校验

 2010-05-31 14:35:00 来源:WEB开发网   
核心提示:import android.view.Window;import android.view.WindowManager;import android.view.View.OnTouchListener;import android.widget.Toast;import android.os.SystemProper

import android.view.Window;

import android.view.WindowManager;

import android.view.View.OnTouchListener;

import android.widget.Toast;

import android.os.SystemProperties;

public class AndroidCalibrate extends Activity {

final String TAG = "ScreenCalibration";

final int UI_SCREEN_WIDTH = 800;

final int UI_SCREEN_HEIGHT = 480;

CrossView myview;

int direction;

private Calibrate cal;

int xList[] = {

50, UI_SCREEN_WIDTH - 50, UI_SCREEN_WIDTH - 50, 50, UI_SCREEN_WIDTH / 2

};

int yList[] = {

50, UI_SCREEN_HEIGHT - 50, UI_SCREEN_HEIGHT - 50, 50, UI_SCREEN_HEIGHT / 2

};

static void setNotTitle(Activity act) {

act.requestWindowFeature(Window.FEATURE_NO_TITLE);

}

static void setFullScreen(Activity act) {

setNotTitle(act);

act.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setFullScreen(this);

myview = new CrossView(this);

setContentView(myview);

SystemProperties.set("ts.config.calibrate", "start");

cal = new Calibrate();

direction = 0;

myview.setOnTouchListener(new OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

Log.i("OnTouch", event.getX() + "," + event.getY());

v.invalidate();

if (direction < 4) {

Log.i("XXW time onTouchListener", " " + direction);

cal.get_sample(direction, (int)event.getX(), (int)event.getY(),

xList[direction], yList[direction]);

}

if (direction == 4) {

上一页  5 6 7 8 9 10 11 12 13  下一页

Tags:Android 实现 触摸屏

编辑录入:coldstar [复制链接] [打 印]
赞助商链接