日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android AlertDialog学习

發布時間:2023/12/10 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android AlertDialog学习 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 有兩個按鈕的對話框

Builder builder=new AlertDialog.Builder(AlertDialogActivity.this); builder.setIcon(android.R.drawable.btn_plus); builder.setTitle("btnplus"); builder.setMessage("去不去?"); builder.setPositiveButton("確定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { Toast.makeText(AlertDialogActivity.this,"你選擇了確定按鈕",Toast.LENGTH_SHORT).show(); } }); builder.setNegativeButton("取消",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { Toast.makeText(AlertDialogActivity.this, "你選擇了取消按鈕",Toast.LENGTH_SHORT).show(); } } ); builder.show(); }

2. ?帶有三個按鈕的對話框

public void onClick(View v) { // TODO Auto-generated method stub new AlertDialog.Builder(AlertDialogActivity.this) .setIcon(android.R.drawable.btn_star).setTitle("溫馨提示").setMessage("提示內容,三個按鈕"). setPositiveButton("確定",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Toast.makeText(AlertDialogActivity.this, "你選擇了確定按鈕", Toast.LENGTH_SHORT).show(); } }) .setNeutralButton("菜單",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub Toast.makeText(AlertDialogActivity.this, "你選擇了詳細按鈕", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("取消",new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog,int which){ Toast.makeText(AlertDialogActivity.this,"你選擇了取消按鈕",Toast.LENGTH_SHORT).show(); } }) .show(); }

3. 能進行輸入的對話框

public void onClick(View v) { // TODO Auto-generated method stub LayoutInflater inflater=LayoutInflater.from(AlertDialogActivity.this); final View textEntryView=inflater.inflate(R.layout.alert_dialog_text_entry,null); final EditText usernameET=(EditText)textEntryView.findViewById(R.id.username_value); final EditText passwordET=(EditText)textEntryView.findViewById(R.id.password_value);new AlertDialog.Builder(AlertDialogActivity.this) .setIcon(android.R.drawable.btn_star) .setTitle("溫馨提示") .setView(textEntryView) .setPositiveButton("確定",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { Toast.makeText(AlertDialogActivity.this,"用戶名="+usernameET.getText().toString()+"\n密碼="+passwordET.getText().toString(),Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("取消",new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog,int which) { Toast.makeText(AlertDialogActivity.this,"你選擇了取消按鈕",Toast.LENGTH_SHORT).show(); } }) .show();



4. 進度條對話框

ProgressDialog dialog=new ProgressDialog(AlertDialogActivity.this); dialog.setTitle("處理中。。。"); dialog.setMessage("請稍等。。。"); dialog.show();


轉載于:https://www.cnblogs.com/cc-Cheng/archive/2012/07/20/2714101.html

總結

以上是生活随笔為你收集整理的Android AlertDialog学习的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。