Original:
http://code.google.com/p/androidbmi/wiki/AndroidDialog
private void openOptionsDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(Bmi.this)
dialog.setTitle(R.string.about_title)
dialog.setMessage(R.string.about_msg)
dialog.setPositiveButton(R.string.ok_label,
new DialogInterface.OnClickListener(){
public void onClick(
DialogInterface dialoginterface, int i){
}
})
dialog.show();
}
}
Add in:
String.xml: about_title, about_msg, ok_label
import: dialoginterface, AlertDialog
p.s. openOptionsDialog => private void
Toast:
別忘了不管是 AlertDialog 或者 Toast,這些函式後都必須加上「show()」方法,這樣提醒訊息才會顯示到螢幕上。
No comments:
Post a Comment