Last active
June 1, 2020 03:12
-
-
Save chelseatroy/d606b4d8e9d85ed4c2fd40c0dfd1ebc6 to your computer and use it in GitHub Desktop.
Change the Top Bar Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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