그래서 때마다 내 안드로이드 응용 프로그램은 unexpectdly 중단이 코드를 실행하고 난 이유를 얻을 해달라고 ...Android 앱이 예상치 않게 멈추고 이벤트 핸들러를 실행하려고합니까?
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.TextView;
public class TheStupidTest extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView text1 = (TextView) findViewById(R.id.TextView01);
text1.setText("well this works at least");
Button yButton = (Button) findViewById(R.id.button_yellow);
yButton.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.equals(MotionEvent.ACTION_UP)) {
text1.setText("You pressed the yellow button");
return true;
}
return false;
}
});
}
}
Android 앱을 디버그하는 방법은 Pentium10의 게시물을 참조하십시오. http://stackoverflow.com/questions/3222608/android-error-the-application-has-stopped-unexpectedly-please-try-again/3223115# 3223115 – ccheneson
DDMS와 logcat을 사용하여 문제를 확인하십시오. http://goo.gl/i9by –
왜 버튼에 대한 'OnClickListener' 대신'OnTouchListener'가 필요합니까? – adamp