0
내 애플리케이션에서 저장 또는 취소 대화 상자를 표시합니다. 사용자가 저장을 클릭하면 새 대화 상자에 텍스트 편집, 날짜 버튼 및 저장 버튼이 표시됩니다. 사용자가 날짜를 클릭하면 날짜 대화 상자가 나타납니다. 하지만 InvocationTargetException을받는 날짜 버튼을 클릭합니다. 이 문제를 어떻게 해결할 수 있습니까?Android에서 대화 상자의 대화 상자를 표시하는 방법은 무엇입니까?
Dialog d = new Dialog(CameraView.this, R.style.Dialog);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.img_info);
loadDate();
d.setCancelable(true);
LoadDate 방법이
private void loadDate(){
// capture our View elements
mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
mPickDate = (Button) findViewById(R.id.pickDate);
// add a click listener to the button
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
// get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
// display the current date (this method is below)
updateDisplay();
}
private void updateDisplay() {
mDateDisplay.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" "));
}
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}