Android tutorials back button navigation in action bar using kotlin - Joklinz-Tech

Latest

Home Of Tech news,jobs and android tutorials

Thursday, 25 January 2018

Android tutorials back button navigation in action bar using kotlin



 val action=supportActionBar        action?.setDisplayShowHomeEnabled(true)

        action?.setIcon(R.mipmap.ic_launcher)
if (supportActionBar!=null){
    action?.setDisplayHomeAsUpEnabled(true)

}



override fun onCreateOptionsMenu(menu: Menu): Boolean {
    // Inflate the menu; this adds items to the action bar if it is present.    menuInflater.inflate(R.menu.menu_ourwebsite, menu)
    return true}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
    // Handle action bar item clicks here. The action bar will    // automatically handle clicks on the Home/Up button, so long    // as you specify a parent activity in AndroidManifest.xml.    val id = item.itemId
     if (id == R.id.action_settings) {
         val i= Intent(this, Main3Activity::class.java)
         startActivity(i)
    }
    if (id == android.R.id.home) {
       finish()
    }

    return super.onOptionsItemSelected(item)

}

No comments:

Post a Comment