Android中模仿IOS中的UIActionSheet,自带IOS6和IOS7两种风格,可以自定义风格,背景图片、按钮图片、文字颜色、间距等。
Github地址:https://github.com/baoyongzhang/ActionSheetForAndroid
/ 创建并显示
ActionSheet.createBuilder(
this
, getSupportFragmentManager())
.setCancelButtonTitle(
"Cancel"
)
.setOtherButtonTitles(
"Item1"
,
"Item2"
,
"Item3"
,
"Item4"
)
.setCancelableOnTouchOutside(
true
).setListener(
this
).show();
// 事件监听
@Override
public
void
onOtherButtonClick(ActionSheet actionSheet,
int
index) {
Toast.makeText(getApplicationContext(),
"click item index = "
+ index,
0
).show();
}
@Override
public
void
onCancel(ActionSheet actionSheet) {
Toast.makeText(getApplicationContext(),
"cancel"
,
0
).show();
}
@Override
public
void
onDismiss(ActionSheet actionSheet) {
Toast.makeText(getApplicationContext(),
"dismissed"
,
0
).show();
}
|