1. 程式人生 > >android中的Dialog相關

android中的Dialog相關

1.在測試時,如何實現一個提示

可以使用

Toast.makeText(this, "這是一個提示", Toast.LENGTH_SHORT).show();
//從資原始檔string.xml 裡面取提示資訊
Toast.makeText(this, getString(R.string.welcome), Toast.LENGTH_SHORT).show();

這個提示會幾秒鐘後消失


2.可以使用AlertDialog.Builder 才產生一個提示框.

例如像messagebox那樣的

new AlertDialog.Builder(this)
.setTitle("Android 提示")
.setMessage("這是一個提示,請確定")
.show();

帶一個確定的對話方塊

new AlertDialog.Builder(this)
.setMessage("這是第二個提示")
.setPositiveButton("確定",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
//按鈕事件