kotlin 写的Android(安卓)toast工具类
16lz
2021-01-24
原文地址:https://rongi.github.io/kotlin-blog/kotlin/2017/06/28/toast.html
Google的时候翻到了一个别人用kotlin实现的toast工具类感觉很棒,特别记录一下:
实现
fun Any.toast(context: Context, duration: Int = Toast.LENGTH_SHORT): Toast { return Toast.makeText(context, this.toString(), duration).apply { show() }}
用法:
"This is my string".toast(context)
"click on ${position.name}".toast(context)
原文地址:https://rongi.github.io/kotlin-blog/kotlin/2017/06/28/toast.html
更多相关文章
- Android(安卓)开源框架
- android条形码二维码
- android repo/git server 建立过程(1)
- 在Android中引入Java8的lambda表达式
- Android(安卓)SDK 在线更新镜像服务器资源
- android UI开源项目
- 一些android错误
- Android(安卓)VideoView通过Intent.ACTION_VIEW播放视频(4)
- Android(安卓)VideoView如何播放RTSP的流