2012-04-20 22 views
0

ボタンをクリックしたときにカスタムダイアログをポップアップしようとしましたが、ポップアップが表示されません。私のアプリは基本的にはカレンダーですが、sqliteを使用して予定を追加/保持し、予定を詳細に指定するダイアログを使用してカレンダーの日付に追加します。私は間違って何をやっているカスタムダイアログが表示されない - Android

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); 
    } 

私はこのために使用しているコードは、次のですか?

答えて

3

ダイアログのshow()メソッドを呼び出します。

createAppmntDialog.show(); //when you want the dialog to appear on the screen 
+0

笑働いたが、何かがAZ1 @私のコード – a7omiton

+0

に間違っている必要がありますので、私は、実行時例外を持って、 'RuntimeException'が...と言っている?ありがとう – Luksprog

+0

04-20 09:16:03.286:E/AndroidRuntime(1188):android.view.WindowManager $ BadTokenException:ウィンドウを追加できません - トークンnullはアプリケーション用ではありません – a7omiton

関連する問題