原文地址:https://github.com/saiwu-bigkoo/Android-AlertView

圖片.png
仿iOS的AlertViewController 幾乎完美還原iOS 的 AlertViewController ,同時支持Alert和ActionSheet模式,每一個細節(jié)都是精雕細琢,并把api封裝成懶到極致模式,一行代碼就可以進行彈窗.
compile 'com.bigkoo:alertview:1.0.3'
new AlertView("上傳頭像", null, "取消", null,
new String[]{"拍照", "從相冊中選擇"},
this, AlertView.Style.ActionSheet, new OnItemClickListener(){
public void onItemClick(Object o,int position){
Toast.makeText(this, "點擊了第" + position + "個",
Toast.LENGTH_SHORT).show();
}
}).show();
//或者builder模式創(chuàng)建
new AlertView.Builder().setContext(context)
.setStyle(AlertView.Style.ActionSheet)
.setTitle("選擇操作")
.setMessage(null)
.setCancelText("取消")
.setDestructive("拍照", "從相冊中選擇")
.setOthers(null)
.setOnItemClickListener(listener)
.build()
.show();
new AlertView("標題", "內(nèi)容", null, new String[]{"確定"}, null, this,
AlertView.Style.Alert, null).show();