求助,鸿蒙中有类似Alert的组件吗?点击确定或者取消提示框才消失,是需要使用ToastDialog自己封装吗?有大神封装过吗?求助求助
鸿蒙开发者奣求助,鸿蒙中有类似Alert的组件吗?点击确定或者取消提示框才消失
4
浏览555 发布于2021-04-26 02:40未知归属地
全部评论
最多点赞
最新发布
最早发布
sunflower开发者你好,请参考:
/**
* 弹出对话框
* @param context 上下文
* @param contentText 对话框内容
* @param titleText 对话框标题
* @param leftButtonText 对话框左边按钮内容
* @param rightButtonText 对话框右边按钮内容
*/
public static void showDialog(Context context,String contentText, String titleText,String leftButtonText,String rightButtonText) {
CommonDialog commonDialog = new CommonDialog(context);
Component dialogLayout = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_layout, null, false);
Text titleView = (Text)dialogLayout.findComponentById(ResourceTable.Id_dialog_title_view);
Button confirmButton = (Button)dialogLayout.findComponentById(ResourceTable.Id_dialog_confirm_button);
Button cancelmButton = (Button)dialogLayout.findComponentById(ResourceTable.Id_dialog_cancel_button);
Text contentDialogText = (Text) dialogLayout.findComponentById(ResourceTable.Id_dialog_content_view);
titleView.setText(titleText);
confirmButton.setText(leftButtonText);
cancelmButton.setText(rightButtonText);
contentDialogText.setText(contentText);
commonDialog.setContentCustomComponent(dialogLayout);
confirmButton.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
}
});
cancelmButton.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.destroy();
}
});
commonDialog.show();
}2楼回复于2021-04-26 08:01 未知归属地
鸿蒙开发者奣好的,谢谢,我去试一试
2021-04-26 08:20 未知归属地
鸿蒙开发者奣您好,xml的布局代码可以发一份吗?我不太清楚这个布局是什么样的
2021-04-27 00:55 未知归属地
eva3w欢迎小伙伴们进来帮帮楼主~~~~~~
1楼回复于2021-04-26 03:45 未知归属地
写回答
所见即所得编辑器, editor1
工具栏 撤消 快捷键 Ctrl+Z 重做 快捷键 Ctrl+Y 格式刷 快捷键 Ctrl+Shift+C 清除格式 加粗 快捷键 Ctrl+B 倾斜 快捷键 Ctrl+I 下划线 快捷键 Ctrl+U 删除线格式调整字号 文本颜色 背景颜色 增加缩进量 减少缩进量 左对齐 居中 右对齐 两端对齐段落间距行间距 项目列表 编号列表 插入水平线 块引用 插入/编辑超链接 快捷键 Ctrl+K 取消超链接 图片 表格 上传附件 导入Word 插入代码 MD编辑器 全屏模式
0/50000
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
相关推荐
换一批
1
源码中的Timer和TimerTask在HarmonyOS中有对应吗?(API12+)
2
HarmonyOS 重力传感器取消监听时抛异常,导致crash (API12+)
3
HarmonyOS 地点搜索API中如何取消上次搜索请求 (API12+)
4
HarmonyOS bindPopup的自定义弹窗中有TextInput,如何规避键盘(在键盘升起时随之升起)(API12+)
5
HarmonyOS Image切圆角时,Image的border里加了width属性,就会变得不规则,取消width就是正常切圆角的效果(API12+)
6
HarmonyOS 如何解决组件消失动画偏移闪烁?(API12+)
7
HarmonyOS 有类似带菊花旋转的提示框的吗?(API12+)
8
HarmonyOS 如何实现气泡提示框?(API12+)
了解社区公约,与您携手共创和谐专业的开发者社区。




































苏公安网备 32011402010933号