안드로이드 개발 질문/답변
(글 수 45,052)
case DIA_INSUJA_ETC: LayoutInflater factory = LayoutInflater.from(this); final EditText ET_INPUTBOX = (EditText)findViewById(R.id.EditText_INPUTBOX); final View textEntryView = factory.inflate(R.layout.inputbox, null); return new AlertDialog.Builder(work.this) .setTitle("기타 인수자입력") .setView(textEntryView) .setPositiveButton("확인", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { work = W_JUNGSAN; TV_INSUJA.setText(ET_INPUTBOX.getText()); showDialog(DIA_JUNGSAN); } }) .setNegativeButton("취소", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { work = W_INSUJA; showDialog(DIA_INSUJA); } }) .create();TV_INSUJA = 텍스브트뷰
ET_INPUTBOX = R.id.EditText_INPUTBOX 안의 EDITTEXT
간단히 다이얼로그의 "확인" 버튼을 누르면 ET_INPUTBOX 에서 텍스트를 가져와서
TV_INSUJA 에 넣으면되는데요 .
로그메세지는
05-18 18:05:05.787: ERROR/AndroidRuntime(5254): Uncaught handler: thread main exiting due to uncaught exception 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): java.lang.NullPointerException 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at korex.test.work$3.onClick(work.java:197) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at android.os.Handler.dispatchMessage(Handler.java:99) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at android.os.Looper.loop(Looper.java:123) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at android.app.ActivityThread.main(ActivityThread.java:4364) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at java.lang.reflect.Method.invokeNative(Native Method) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at java.lang.reflect.Method.invoke(Method.java:521) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-18 18:05:05.787: ERROR/AndroidRuntime(5254): at dalvik.system.NativeStart.main(Native Method)이고 197번째줄이
TV_INSUJA.setText(ET_INPUTBOX.getText());
구절입니다 .
왜널인 걸까요 ㅠ_ㅠ
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.inputbox, null);
return new AlertDialog.Builder(work.this)
.setTitle("기타 인수자입력")
.setView(textEntryView)
.setPositiveButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
work = W_JUNGSAN;
final EditText ET_INPUTBOX = (EditText)textEntryView.findViewById(R.id.EditText_INPUTBOX);
TV_INSUJA.setText(ET_INPUTBOX.getText());
showDialog(DIA_JUNGSAN);
}
})
.setNegativeButton("취소", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
work = W_INSUJA;
showDialog(DIA_INSUJA);
}
})
.create();
하면되는군요 -ㅅ- ;;;