kotlin牛逼的语法,baseActivity

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 13:54   65   0
BaseActivity kotlin 简单Toast事例代码

abstract class BaseActivity : Activity(){
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
         initView()
        initData()
    }

    abstract fun initData()

    abstract fun initView()
    protected fun toast(ctx : Context,toast_text : String,toast_time:Int = Toast.LENGTH_SHORT){
        Toast.makeText(ctx,toast_text,toast_time).show()
    }

}
继承BaseActivity的使用方法
toast(this,"this is my world")
toast(this,"this is my wrold",
 Toast.LENGTH_SHORT
)
--------------------
toast_time : Int
在子类里面可被重新定义
——————————

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP