I am new to Android and Stack Overflow. I started developing an Android application and I am interested in two things:
1) Is it possible to parameterize a TextView? Suppose I want to display a text message that says something like: "User age is 38." Assume that the age of the user is the result of an algorithm. Using some typical i18n infrastructure, I would write something like "User age - {0}" in my i18n file. Then at runtime I would populate the parameters accordingly. I was not able to figure out how to do this or a similar approach in Android.
2) Suppose I have a complex object with many fields. For example: PersonModel, which has an id, name, age, country, favorite video game, whatever. If I want all this information to be displayed in one layout in one of my actions, the only way I found is to get all the necessary text elements by identifier, and then fill them one by one through the code. I was wondering if there is any binding / snapping mechanism in which I can execute something like: render (myPerson, myView), and this automatically reflects each property of the model into each of the TextView. If someone has ever worked with SpringMVC, Im looking for something similar to their mechanism for mapping objects / object models to views (e.g. spring: forms).
Thank you very much for your help. Hope this is useful for someone else =) Goodbye!
source
share