onTouchEvent not fire in DroidGap
I have been develop with Phonegap 2.9. In Manactivity.java (i extend
DroidGap) i use event onTouchEvent but it not fire when i touch. When
Manactivity.java (i extend Activity) then it working. Anyone can help me.
Thank you very much.
public class MainActivity extends DroidGap{
private static final String DEBUG_TAG = "onTouchListener";
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
CookieManager.setAcceptFileSchemeCookies(true);
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/viewer.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
//It not fire when touch
public boolean onTouchEvent(MotionEvent e) {
int num = e.getPointerCount();
for (int a = 0; a < num; a++) {
int x = (int) e.getX(e.getPointerId(a));
int y = (int) e.getY(e.getPointerId(a));
Toast.makeText(this, "x = " + x + ", y = " + y,
Toast.LENGTH_LONG).show();
Log.d(DEBUG_TAG, "pointer_" + e.getPointerId(a) + ": x = " + x
+ ", y = " + y);
}
return false;
}
No comments:
Post a Comment