import android.os.Bundleimport android.app.Activityimport android.content.Intentimport view.Rclass Main2Activity : Activity() {    override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        setContentView(R.layout.activity_main2)        findViewById(R.id.button).setOnClickListener { buttonclick() }
//直接传方法,这跟swift一样,可以说这是一种动态语法的优势,直接传也方法作为参数,比JAVA方便很多        findViewById(R.id.button2).setOnClickListener { button2click() }        findViewById(R.id.button3).setOnClickListener { button3click() }    }    private fun buttonclick() {        startActivity( Intent(this, PullRefActivity().javaClass))    }    private fun button2click() {       startActivity( Intent(this, DropActivity().javaClass))    }    private fun button3click() {        startActivity(Intent(this, SiwpeActivity().javaClass))    }}

更多相关文章

  1. Unable to start activity ComponentInfo 解决方法
  2. Android 安装apk的方法
  3. Android SQLite数据库解析并使用两种方法实现增删改查
  4. Android 读取XML的两种方法。
  5. android window.requestWindowFeature()常用方法
  6. MediaExtractor的seekTo方法精确定位到指定帧
  7. android ImagView缩放方法之一(Bitmap)
  8. Android通过Uri获取文件的路径的方法
  9. android使用全局变量的方法

随机推荐

  1. MySQL数据库导入导出数据之报错解答实例
  2. MySQL线上死锁分析实战
  3. MySQL 触发器的使用和理解
  4. MySQL 字段默认值该如何设置
  5. MySQL 字符串拆分实例(无分隔符的字符串
  6. MySQL 字符串拆分操作(含分隔符的字符串
  7. MySQL实现字符串的拼接,截取,替换,查找位
  8. mysql 多个字段拼接的实例详解
  9. MySQL存储过程的查询命令介绍
  10. 解决Mysql报Invalid default value for &