Suppose I have a list of items like this:
List<User> mPersonList=getAllUser();
Then I want to display them in the activity, I have two ideas:
1 Use the ListView
I will create a Custom adapter extending from ArrayAdapter
to bind the data to the view. This this the general idea.
But sometimes, the parent of a ListView
may(must) be a ScrollView
, so someone suggest me use the Linearlayout
.
2 Use something like the LinearLayout
.
Create one LinearLayout
for each item, and add them to the parent view.
For example:
ViewGroup parent=(ViewGroup)findViewById(R.id.xx):
for(Person p : mPersonList){
LinearLayout ll=new LinearLayout(...) //created by constructor
// or ll=mlayerInflate.inflate(R.layout.xxx);
TextView tv=new TextView(..)
tv.setText(p.name);
ll.addView(tv);
parent.addView(ll);
}
I wonder if which is better when performance considered?