首页 > 编程知识 正文

toast使用方法,android取消toast

时间:2023-05-05 09:31:31 阅读:108887 作者:24

在使用qml编程的过程中,执行某些任务后可能需要结果提示。 然后,这个提示在等待几秒钟后自动消失。 这就是Toast提示。 本文介绍用qml表示Toast效果。 具体的示例代码如下。

//toast.qmlimportqtquick 2.12 rectangle { id : toastpropertyreadonlypropertyrealdefaulttime 33603000 refaulttime efault time 3603000 realfadetime :300 propertyrealmargin :10 propertyboolselfdestroying 336090 false width :98 height :98 radid 3360 ' # 000000 ' anchors.horizontal center : parent.horizontalcenterfunctionshow { text,duration } { the text.text }==' undefined ' (if (duration=2* fade time ) time=duration; else time=2*fadeTime; } else time=defaultTime; anim.start (; } image { id : imgheaderanchors.top : parent.top anchors.top margin 336013 anchors.horizontal center 3360 parent.horizors rce : ' qrc :/image/notice _ 50.SVG ' } text { id : the texttext : " " horizontal alignment : text.alignhcenterx 336028 y :68 font.pixel size 336014 color 336660 sssser 360 anim running : falsenumberanimation { to :9 duration : fade time } pause animation { duration : time-2 * fade time } number animation { to : duration : fade time } onrunningchanged 3360 { runningselfdestroying (toast.destroy ); }//toast manager.qmlimportquick 2.12 column { functionshow,duration } { vartoast=toast component.createobjon } toast.toast toast.show(text,duration ); } id : toastmanagerz 3360信息空间:5 anchors.center in : parentpropertyvartoastcomponentcomponent.on completed 33333 . QML ' )/main.qmlimportqtquick 2.12 importqtquick.window 2.12 window { visible :640 true width 3360640 height 3360480 title 3360 qsqsqqquick height :50 color : ' red ' anchors.top : parent.top anchors.left : parent.leftmousearea { anchors.fill 3360 p PP height :50 color : ' blue ' anchors.top : parent.top anchors.rightmousearea { anchors.fill :

参考:用QML用安卓打造Toast-Java学习之路

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。