tencent cloud

Tencent Cloud Super App as a Service

문서Tencent Cloud Super App as a Service

ActionSheet

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-09-24 16:41:40
Note:
The SDK includes scenarios where the ActionSheet is displayed, such as when the mini program calls wx.showActionSheet. Superapps can customize the ActionSheet by overriding the AbsMiniUiProxy.showActionSheet API.
ActionSheetInfo: Includes basic ActionSheet information such as the title, options, and event listeners. Developers can create ActionSheet based on the information.
/**
* General ActionSheet display API
* @param context Context
* @param actionSheetInfo ActionSheet information
* @return true if using a custom ActionSheet; false if using the SDK's default ActionSheet
*/
boolean showActionSheet(Activity context, ActionSheetInfo actionSheetInfo);
Example
@Override
public boolean showActionSheet(Activity context, ActionSheetInfo actionSheetInfo) {
ActionSheet actionSheet = ActionSheet.create(context);

// Set the title
if (actionSheetInfo.getTitle() != null) {
actionSheet.setMainTitle(actionSheetInfo.getTitle());
}

// Set whether the configuration can be cancelled
actionSheet.setCancelable(actionSheetInfo.isCancelable());

// Add items
if (actionSheetInfo.getItems() != null) {
for (ActionSheetItem item : actionSheetInfo.getItems()) {
if (item.getTextColor() != null) {
actionSheet.addButton(item.getText(), ActionSheet.CUSTOM_TEXT_COLOR_BTN,
String.format("#%08X", item.getTextColor()));
} else {
actionSheet.addButton(item.getText(), ActionSheet.GRAY_STYLE_BTN);
}
}
}

// Set the text on the Cancel button
if (actionSheetInfo.getCancelText() != null) {
actionSheet.addCancelButton(actionSheetInfo.getCancelText());
}

// Set the tap listener
if (actionSheetInfo.getItemClickListener() != null) {
actionSheet.setOnButtonClickListener(new ActionSheet.OnButtonClickListener() {
@Override
public void onClick(View clickedView, int which) {
actionSheetInfo.getItemClickListener().onClick(which);
actionSheet.dismiss();
}
});
}

// Set the cancellation listener
if (actionSheetInfo.getCancelListener() != null) {
actionSheet.setOnDismissListener(new ActionSheet.OnDismissListener() {
@Override
public void onDismiss() {
actionSheetInfo.getCancelListener().onCancel(null);
}
});
}

if (!context.isFinishing() && !actionSheet.isShowing()) {
actionSheet.show();
}
return true;
}



도움말 및 지원

문제 해결에 도움이 되었나요?

피드백