2010-12-03 4 views
0

내 응용 프로그램에서 AlertDialog 후에 축배를 보여 주려고하는데 성공하지 못했습니다!DialogAlert 후 토스트

public class DeletePatient extends ListActivity{ 

private String[] listItems; 

    private static final int DIALOG_YES_NO_MESSAGE = 1; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.deletepatient); 
     setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems=new Patient().seePatient())); 
} 

@Override 
    protected void onListItemClick(ListView l, View v, int position, long id) { 
     super.onListItemClick(l, v, position, id); 

     showDialog(DIALOG_YES_NO_MESSAGE); 

     } 

    @Override 
    protected Dialog onCreateDialog(int id) { 
     switch (id) { 
     case DIALOG_YES_NO_MESSAGE: 
      return new AlertDialog.Builder(DeletePatient.this) 

       .setTitle(R.string.deletepatient) 
       .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { 

    public void onClick(DialogInterface dialog, int whichButton) { 

     Toast.makeText(getApplicationContext(), "Something to display", Toast.LENGTH_SHORT);      
        } 
       }) 
       .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 


        } 
       }) 
       .create(); 
     } 
    return null; 

    } 


} 

답변

8
Toast.makeText(getApplicationContext(), "Something to display", 
    Toast.LENGTH_SHORT).show(); 

는 토스트에서 호출 더 show() 없습니다. 코드를 변경하십시오.

관련 문제