Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change the Top Bar Text
class MainActivity : AppCompatActivity(), Updatable {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//CHANGING THE TEXT OF THE TOP BAR
val toolbarTitle = findViewById<TextView>(R.id.title)
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
var name = preferences.getString("Name", "")
if (!name.equals("", ignoreCase = true)) {
toolbarTitle.text = getString(R.string.greeting, name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.