Android Dialog用法总结
2010-05-31 17:27:00 来源:WEB开发网setContentView(R.layout.main);
btnTEDlg = (Button)findViewById(R.id.teBtn);
btnTEDlg.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
LayoutInflater factory = LayoutInflater.from(TextEntryDialogTest.this);
final View textEntryView = factory.inflate(R.layout.text_entry_dialog, null);
AlertDialog dlg = new AlertDialog.Builder(TextEntryDialogTest.this)
.setTitle("User Login")
.setView(textEntryView)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
})
.create();
dlg.show();
}
});
}
}
更多精彩
赞助商链接