このコードの問題は何ですか?
package com.evorlor.samplecode;
import android.app.Activity;
public class MotionEvent extends Activity {
public boolean onTouchEvent(MotionEvent me) {
int i = me.getAction();
switch (i) {
case MotionEvent.ACTION_DOWN:
// When your finger touches the screen
break;
case MotionEvent.ACTION_UP:
// When your finger stop touching the screen
break;
case MotionEvent.ACTION_MOVE:
// When your finger moves around the screen
break;
}
return false;
}
}
エラーが発生しています:
メソッドgetAction()は、.getAction()のタイプMotionEventに対して未定義です。インポートできません:
import android.view.MotionEvent;
私が知る限り、これはこの動作するコードと同じです(import android.view.MotionEvent;をインポートできないことを除けば):
package com.evorlor.counter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
public class Counter extends Activity {
private static int count = 0;
private static int hiCount = 0;
private static boolean capCount = false;
public static boolean resetCount = false;
public static boolean askReset = false;
public boolean onTouchEvent(MotionEvent me) {
if (me.getAction() == MotionEvent.ACTION_UP) {
count++;
}
onCreate(null);
return false;
}
}
助けてくれてありがとう!