0
你好,即时制作一个Android应用程序,它使用地理位置/谷歌地图,没有按钮在地图/应用程序,除了选项卡主机。所以我需要它,所以如果用户点击了1500毫秒,然后一个对话框出现,到目前为止,没有任何反应,但我在这里没有错误是我的代码预先感谢Android Motionevent覆盖
class Touchy extends Overlay{
public boolean ontouchevent(MotionEvent e, MapView m){
if (e.getAction() == MotionEvent.ACTION_DOWN){
start = e.getEventTime();
}
if (e.getAction() == MotionEvent.ACTION_UP){
stop = e.getEventTime();
}
if (stop - start > 1500){
AlertDialog alert = new AlertDialog.Builder(SPtouch2fixActivity.this).create();
alert.setTitle("Alert");
alert.setMessage("This is an alert");
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
alert.setButton2("Update Geolocation", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
alert.setButton3("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
alert.show();
return true;
}
return false;
}
}
}
这不是解决方案,但应该有助于揭示原因:'onTouchEvent'与'ontouchevent'不同。 – 2012-11-08 17:41:04