Change Actionbar title of an activity programmatically (Kotlin)- Android Studio

In this tutorial we will change the title of Actionbar of an Activity in Kotlin using Android Studio...

Step 1: Create a new Project OR Open you project

Step 2: Code

MainActivity.kt
package com.blogspot.atifsoftwares.kotlinpractice

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        //to change title of activity
        val actionBar = supportActionBar
        actionBar!!.title = "New Title"

    }
}

Step 3: Output


Comments

Popular posts from this blog

Picture In Picture | Android Studio | Kotlin

Manage External Storage Permission | Android Studio | Kotlin

How to add AIDL folder | Android Studio