new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(R.string.alert_dialog_two_buttons_msg)
.setMessage(R.string.alert_dialog_two_buttons2_msg)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNeutralButton(R.string.alert_dialog_something, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked Something so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked Cancel so do some stuff */
}
})
.create();
public void dialog(){
Context DialogContext=SearchWineActivity.this;
AlertDialog.Builder builder;
Context mContext=TestActivity.this;
LayoutInflater inflater=(LayoutInflater)mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog, null);
//-------------------------------
content
추가. dialog.xml에 있는것은 다이얼로그에 속하지 않은 뷰입니다.
그래서 findViewById앞에 view인자를 써주셔야 합니다.(주의)
ex)
SeekBar mSeekBarPenWidth = (SeekBar) layout.findViewById(R.id.seekbarpenwidth);
//-------------------------------
builder=new AlertDialog.Builder(DialogContext);
alertDialog=builder.create();
alertDialog.show();
alertDialog.setContentView(layout);
}
댓글 영역