如何在处理程序中将java转换为kotlin

2022-09-02 02:25:15

如何在处理程序中将java转换为kotlin

new Handler().postDelayed(new Runnable(){
    @Override
    public void run() {
        /* Create an Intent that will start the Menu-Activity. */
        Intent mainIntent = new Intent(Splash.this,Menu.class);
        Splash.this.startActivity(mainIntent);
        Splash.this.finish();
    }
}, 3000);

答案 1
Handler(Looper.getMainLooper()).postDelayed({
    /* Create an Intent that will start the Menu-Activity. */
    val mainIntent = Intent(this, Menu::class.java)
    startActivity(mainIntent)
    finish()
}, 3000)

答案 2

推荐