2015年7月21日

Toast 訊息提示

Toast 訊息提示



Toast.makeText(MainActivity.this, "提示內容",Toast.LENGTH_SHORT ).show();

提示框在顯示之後過了幾秒就會消失,是一種短暫的訊息,可以做為輸入狀況的提示。

AlertDialog 對話框

AlertDialog 對話框

import android.app.AlertDialog;

private void openDialog() {
new AlertDialog.Builder(this)
       .setTitle("Google Play Service")
       .setMessage("Not Connect !")
.setPositiveButton("Yes"
, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 按下按鈕後執行的動作,無編輯則退出Dialog
}
}).show();
}