Approach 1: In an android app there is shown a duration TextView (like: "2 h 45 m") and another TextView with number of Stops (like: "Stops: 15"). Between them is another TextView (" | ") to separate them.
Approach 2: using only one TextView, a String template and concatenation to put it together.
Consider the data (2 45 and 15) comes from backend and the number of stops isn't really logically connected to the duration.
My Question is:
Which approach is more efficient considering performance and code-maintainability? Is there a better way of doing this or are there any best practices?
Thank you
You don't need multiple TextViews for this. You have a format and just want to put values in there. I would suggest the following way
int h = 2;
int m = 45;
int s = 15;
String format = String.format("%dh %dm | Stops: %d ", h, m, s);
Now assign format
string to your one TextView