0
私のアプリは正常に機能していませんでしたが、ジェスチャー(チュートリアルのコード)を追加してから実行中にクラッシュします。 ジェスチャーサポートを追加した後にAndroidがクラッシュする
package com.mystraldesign.memorable;
import android.app.Activity;
//import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGestureListener;
import android.graphics.Typeface;
import android.os.Bundle;
//import android.widget.RelativeLayout;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.MotionEvent;
import android.view.Window;
import android.widget.TextView;
public class MemorableActivity extends Activity implements OnGestureListener,OnDoubleTapListener
{
//Define text views
private TextView textView1;
private TextView textView2;
private TextView textView3;
private TextView textView4;
//Gesture Detectors
private GestureDetector gTap;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
gTap = new GestureDetector(this,(android.view.GestureDetector.OnGestureListener) this);
//Remove title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
//Define textView
textView1 = (TextView) findViewById(R.id.textView1);
textView2 = (TextView) findViewById(R.id.textView2);
textView3 = (TextView) findViewById(R.id.textView3);
textView4 = (TextView) findViewById(R.id.textView4);
//Load font file
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/optima.ttf");
//Set various textViews to font
textView1.setTypeface(type);
textView2.setTypeface(type);
textView3.setTypeface(type);
textView4.setTypeface(type);
}
public boolean onTouchEvent(MotionEvent me){
this.gTap.onTouchEvent(me);
return super.onTouchEvent(me);
}
public boolean onDown(MotionEvent e) {
textView1.setText("Down");
return false;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
textView1.setText("Fling");
return false;
}
public void onLongPress(MotionEvent e) {
textView1.setText("Long Press");
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
textView1.setText("Scroll");
return false;
}
public void onShowPress(MotionEvent e) {
textView1.setText("Show Press");
}
public boolean onSingleTapUp(MotionEvent e) {
textView1.setText("Sing Tap Up");
return false;
}
public boolean onDoubleTap(MotionEvent e) {
textView1.setText("Double Tap");
return false;
}
public boolean onDoubleTapEvent(MotionEvent e) {
textView1.setText("Double Tap Event");
return false;
}
public boolean onSingleTapConfirmed(MotionEvent e) {
textView1.setText("Single Tap Confirmed");
return false;
}
}
は、私は彼らとエラーを述べたのEclipseなどの各メソッドの開始から@Overrideなステートメントを削除し、@Override文を削除する自動修正を行いました。
またあるpublic class MemorableActivity extends Activity implements OnGestureListener,OnDoubleTapListener
ライン上のエラーました:
Multiple markers at this line
- The type MemorableActivity must implement the inherited abstract method
GestureOverlayView.OnGestureListener.onGestureEnded(GestureOverlayView, MotionEvent)
- The type MemorableActivity must implement the inherited abstract method
GestureOverlayView.OnGestureListener.onGestureCancelled(GestureOverlayView, MotionEvent)
- The type MemorableActivity must implement the inherited abstract method
GestureOverlayView.OnGestureListener.onGestureStarted(GestureOverlayView, MotionEvent)
- The type MemorableActivity must implement the inherited abstract method
GestureOverlayView.OnGestureListener.onGesture(GestureOverlayView, MotionEvent)
それは私が最初の二つを試してみましたが、それはまだクラッシュと私はよく分からない
Add unimplemented methods
Make MemorableActivity abstract
Rename in file
Rename in workspace
の修正を提案します2番目と3番目のものは/何ですか。
ザ・ログに何のように見えるが、ここでは、コンソール
[2012-04-30 03:54:37 - Memorable] ------------------------------
[2012-04-30 03:54:37 - Memorable] Android Launch!
[2012-04-30 03:54:37 - Memorable] adb is running normally.
[2012-04-30 03:54:38 - Memorable] Performing com.mystraldesign.memorable.MemorableActivity activity launch
[2012-04-30 03:54:38 - Memorable] Automatic Target Mode: launching new emulator with compatible AVD 'Memorable'
[2012-04-30 03:54:38 - Memorable] Launching a new emulator with Virtual Device 'Memorable'
[2012-04-30 03:54:44 - Emulator] 2012-04-30 03:54:44.155 emulator-arm[2796:1107] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2012-04-30 03:54:44 - Memorable] New emulator found: emulator-5554
[2012-04-30 03:54:44 - Memorable] Waiting for HOME ('android.process.acore') to be launched...
[2012-04-30 03:55:36 - Memorable] HOME is up on device 'emulator-5554'
[2012-04-30 03:55:36 - Memorable] Uploading Memorable.apk onto device 'emulator-5554'
[2012-04-30 03:55:41 - Memorable] Installing Memorable.apk...
[2012-04-30 03:55:57 - Memorable] Success!
[2012-04-30 03:55:57 - Memorable] Starting activity com.mystraldesign.memorable.MemorableActivity on device emulator-5554
[2012-04-30 03:56:00 - Memorable] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mystraldesign.memorable/.MemorableActivity }
EDITから出力されていません:Eclipseの
04-30 05:43:25.339: D/AndroidRuntime(333): Shutting down VM
04-30 05:43:25.339: W/dalvikvm(333): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-30 05:43:25.369: E/AndroidRuntime(333): FATAL EXCEPTION: main
04-30 05:43:25.369: E/AndroidRuntime(333): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mystraldesign.memorable/com.mystraldesign.memorable.MemorableActivity}: java.lang.ClassCastException: com.mystraldesign.memorable.MemorableActivity
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.os.Looper.loop(Looper.java:123)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-30 05:43:25.369: E/AndroidRuntime(333): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 05:43:25.369: E/AndroidRuntime(333): at java.lang.reflect.Method.invoke(Method.java:507)
04-30 05:43:25.369: E/AndroidRuntime(333): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-30 05:43:25.369: E/AndroidRuntime(333): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-30 05:43:25.369: E/AndroidRuntime(333): at dalvik.system.NativeStart.main(Native Method)
04-30 05:43:25.369: E/AndroidRuntime(333): Caused by: java.lang.ClassCastException: com.mystraldesign.memorable.MemorableActivity
04-30 05:43:25.369: E/AndroidRuntime(333): at com.mystraldesign.memorable.MemorableActivity.onCreate(MemorableActivity.java:33)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 05:43:25.369: E/AndroidRuntime(333): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-30 05:43:25.369: E/AndroidRuntime(333): ... 11 more
LogCatの出力を貼り付けてください。これをチェックします: 'android.gesture.GestureOverlayView.OnGestureListener'を実装していますが、' gTap = new GestureDetector(this、(android.view.GestureDetector.OnGestureListener)this)の 'android.view.GestureDetector.OnGestureListener'に型キャストしています。 ' – Rajesh
logcat出力を投稿してください。投稿したのはコンソール出力です。 – user936414
@Rajeshログ出力を追加しました。また、gTap = new部分では、これはEclipseで検出された別のエラーと自動修正です。私はビットを後で追加しませんでした(これは、 – jskrwyk