안드로이드 개발 질문/답변
(글 수 45,052)
Java 파일
package dfdfdfc.ll;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class FdfdfdfActivity extends Activity {
/** Called when the activity is first created. */
Button btn;
EditText edt;
TextView txt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
edt=(EditText)findViewById(R.id.edit1);
btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Context mContext = FdfdfdfActivity.this;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,(ViewGroup) findViewById(R.id.layout_root));
AlertDialog.Builder aDialog = new AlertDialog.Builder(FdfdfdfActivity.this);
aDialog.setTitle("현재 페이지");
aDialog.setView(layout);
aDialog.setPositiveButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String str = edt.getText().toString();
txt.setText(str);
}
});
aDialog.setNegativeButton("취소", null);
AlertDialog ad = aDialog.create();
ad.show();
}
});
}
}
coustom_dailog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:digits="0123456789"
android:hint="ex) 이동하실페이지를 입력하세요.">
</EditText>
</LinearLayout>
안녕하세요.. 커스텀을 만들고 셋뷰를 시켰는데
검은색 두꺼운 부분에 값이 자꾸 " "이렇게 들어와 App 종료가 되는현상이 발생하고있습니다.ㅠ
왜 그런지 이유를 알고 싶습닏.




edt=(EditText)findViewById(R.id.edit1);
edt는 액티비티에 있는 에디트박스를 가리키고 있어요. 다이얼로그 에디트박스랑은 상관없습니다.