0

当我单击一个按钮时,我试图弹出一个自定义对话框,但它根本不会弹出。我的应用程序基本上是一个日历,我将使用 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);
    }

我究竟做错了什么?

4

1 回答 1

3

调用show()对话框的方法。

createAppmntDialog.show(); //when you want the dialog to appear on the screen
于 2012-04-20T09:05:43.573 回答