Suppose I have a CardView
which contains 2 TextView
, and I need to display 10 CardView
with same layout as 10 times one below the other
These 10 will always be fixed, it will never be more or less than 10 in the future.
What would be a better approach among the 2 given below (in terms of performance)?
1st Approach :
Type the code for all the 10 CardView
in xml 10 times and set their individual TextView
's value in Java Code
2nd approach :
Type the code for only one CardView
and use it in a "ListView
" or "RecyclerView
" to display it 10 times in Java code
Or can you suggest any other approach?