public class NewAlertDialog{
public AlertDialog.Builder builder;
public AlertDialog alertDialog;
public ProgressDialog progressDialog;
private Context context;
public NewAlertDialog(Conetxt context){
setContext(context);
builder = new AlertDialog.Builder(context,R.style.xxx);
}
public void setContext(Context context){
this.context = context;
}
public void getContext(){
return context;
}
//創(chuàng)建帶左右按鈕的對(duì)話框
public void makeAlertDialog(String title ,String message,String leftButtonText,String rightButtonText,DialogInterface.OnClickListener enterListener,DialogInterface.OnClickListener cancleListener)
builder.setTitle(title);
.setMessage(message);
.setPositiveButton(rightButtonText,enterListener)
.setNegativeButton(leftButtonText,cancelListener)
;
alertDialog=builder.show();
}
//dialog呈現(xiàn)無標(biāo)題列表
public void makeAlertDialogForListItem(String title,String items[],DialogInterface.OnClickListener listener){
builder.setTitle(title)
.setItems(items.listener)
builder.create;
}
//dialog呈現(xiàn)EditText
public void makeAlertDialogForTextView(String title ,View view,String leftButtonText,String rightButtonText,DialogInterface.OnClickListener enterListener,DialogInterface.OnClickListener cancleListener){
builder.setTitle(title)
.setView(view)
.setPositiveButton(rightButtonText,enterListener)
.setNegativeButton(leftButtonText,cancleListener)
alertDialog = builder.show();
}
//創(chuàng)建只帶中間按鈕的對(duì)話框
public void makeNeutralAlertDialog(String title,String message,String buttonText,DialogInterface.OnclickListener enterListener){
builder.setTitle(Title)
.setMessage(message)
.setPositiveButton(buttonText,enterListener)
.create();
alertDialog = builder.show();
alertDialog.setCancleButton(false);
alsetDialog.setCancledOnTouchOutSide(false);//點(diǎn)擊非Dialog區(qū)域不會(huì)關(guān)閉對(duì)話框
}
//創(chuàng)建帶ProgressBar的可以按返回鍵取消的Dialog
public void makeProgressDialog(String title,Stirng message,DialogInteerface.OnclickListener onKeyListener,boolean canClose){
progressDialog = ProgressDialog.show(context,title,message);
progressDialog.setOnKeyListener(onKeyListener);
progressDialog.setCancleable(canClose);
progressDialog.setCancledOnTouchOutSide(false);
progressDialog.show();
}
```
Android AlertDialog和ProgressDialog
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門剩瓶,熙熙樓的掌柜王于貴愁眉苦臉地迎上來驹溃,“玉大人城丧,你說我怎么就攤上這事⊥愫祝” “怎么了亡哄?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)布疙。 經(jīng)常有香客問我蚊惯,道長(zhǎng),這世上最難降的妖魔是什么灵临? 我笑而不...
- 正文 為了忘掉前任截型,我火速辦了婚禮,結(jié)果婚禮上俱诸,老公的妹妹穿的比我還像新娘菠劝。我一直安慰自己,他們只是感情好睁搭,可當(dāng)我...
- 文/花漫 我一把揭開白布赶诊。 她就那樣靜靜地躺著,像睡著了一般园骆。 火紅的嫁衣襯著肌膚如雪舔痪。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼重窟,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了惧财?” 一聲冷哼從身側(cè)響起巡扇,我...
- 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎垮衷,沒想到半個(gè)月后厅翔,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡搀突,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年刀闷,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站花墩,受9級(jí)特大地震影響悬秉,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜冰蘑,卻給世界環(huán)境...
- 文/蒙蒙 一和泌、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧祠肥,春花似錦武氓、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至剂桥,卻和暖如春忠烛,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背权逗。 一陣腳步聲響...
- 正文 我出身青樓师坎,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親堪滨。 傳聞我的和親對(duì)象是個(gè)殘疾皇子胯陋,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 先上圖 ProgressDialog對(duì)于Android開發(fā)者來說已經(jīng)是老朋友了,本意是進(jìn)度對(duì)話框椿猎,常用于更新包下載...
- 在學(xué)習(xí)Android布局的過程中惶岭,我經(jīng)常會(huì)混淆android:gravity和android:layout_gra...
- 在android系統(tǒng)中寿弱,我們可以通過在xml資源文件中定義布局犯眠,一般的寫法是: 包括自定義view在內(nèi)的所有Vie...
- “老婆筐咧,我愛你”,我用心的對(duì)正在奶娃的老婆說×咳铮“老公铺罢,我也愛你”,老婆回得很給面子残炮【伦福“老婆,我們要幸福的生活势就,過上...
- 現(xiàn)在是信息時(shí)代苞冯,大量的信息有如井噴袖牙,不可能都去了解,這樣做是沒意義的舅锄,因?yàn)樾畔⑿枰Y選掉大量的無用信息鞭达,有價(jià)值的信...