January 2019
Intermediate to advanced
392 pages
10h 11m
English
In the activity_main.xml, we have added a FloatingActionButton, which we will use to go to NewUserActivity. To complete this task, use the following code in the onCreate() with the mentioned request code:
fab.setOnClickListener { val intent = Intent(this@MainActivity, NewUserActivity::class.java) startActivityForResult(intent, requestCode) /*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show()*/}
So, here is the complete code of MainAcivity.kt:
class MainActivity : AppCompatActivity() { private val requestCode: Int = 1 private lateinit var mMainViewModel: MainViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout. ...
Read now
Unlock full access