[英]Custom Dialog not displaying - Android
當我單擊一個按鈕時,我試圖彈出一個自定義對話框,但根本不會彈出。 我的應用程序基本上是一個日歷,我將使用sqlite通過對話框在日歷中的日期中添加/保留約會和內容,在該對話框中將指定約會詳細信息。
我為此使用的代碼如下:
public void onClick(View v) {
// TODO Auto-generated method stub
//long a = calendar.getDate();
switch(v.getId()){
case R.id.createButton:
openCreateAppointmentDialog();
break;
}
}
private void openCreateAppointmentDialog(){
Context mContext = getApplicationContext();
Dialog createAppmntDialog = new Dialog(mContext);
createAppmntDialog.setContentView(R.layout.create);
createAppmntDialog.setTitle(R.string.createTitle);
appointmentTitle = (EditText) createAppmntDialog.findViewById(R.id.titleTextBox);
appointmentTitle.setText("hello");
appointmentTime = (EditText) createAppmntDialog.findViewById(R.id.timeTextBox);
appointmentDetails = (EditText) createAppmntDialog.findViewById(R.id.detailsTextBox);
saveAppointment = (Button) createAppmntDialog.findViewById(R.id.saveButton);
saveAppointment.setOnClickListener(this);
}
我究竟做錯了什么?
調用對話框的show()
方法。
createAppmntDialog.show(); //when you want the dialog to appear on the screen
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.