Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active June 1, 2020 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/d606b4d8e9d85ed4c2fd40c0dfd1ebc6 to your computer and use it in GitHub Desktop.
Save chelseatroy/d606b4d8e9d85ed4c2fd40c0dfd1ebc6 to your computer and use it in GitHub Desktop.
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