I'm creating an app in which an user must connect himself. I'm trying to implement a menu, in which the first item text would be the name of the connected user and once clicked on, it would bring to the user profile. To store the connected user information, I created my own subclass of android.app.Application, which contains, amongst others, the connected user:
private User currUser;
public User getCurrUser() {
return this.currUser;
}
public void setCurrUser(User currUser) {
this.currUser = currUser;
}
I was wondering how can I access to this global variable, in my menu XML file, so that the title of the first item would be the connected user name? Logically, I would do something like that:
<item android:id="@+id/action_profil" android:title=(MyApp)this.getApplication().getCurrUser().getM_UserName()
android:orderInCategory="100" app:showAsAction="never" />
But I know this is not doable in XML. How would I do this? Perhaps, I should re-title the item somewhere else?
Thanks.
No comments:
Post a Comment