I have created an app with a page that need to load content dynamically from web service. I want to have listview that can scroll together with a linear layout inside Nested
Instead of add a ListView below a Linear Layout and inside a ScrollView, I would suggest to put everything inside the ListView.
Yes you can.
Implement (override) following method on your adapter:
public class MyAdapter extends BaseAdapter {
// One view to Header
// One view to filter options ("most helpful first" and "Options")
// One view to comments
private final static int VIEW_HEADER = 0;
private final static int VIEW_OPTIONS = 1;
private final static int VIEW_COMMENTS = 2;
private final static int VIEW_TYPE_MAX = 3;
@Override
public int getViewTypeCount () {
// It will return 3 since I have 3 different types of VIEW
return VIEW_TYPE_MAX;
}
@Override
public int getItemViewType(int position) {
if (position == 0)
return VIEW_HEADER;
else if (position == 1)
return VIEW_OPTIONS;
else
return VIEW_COMMENTS;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
if(getItemViewType(position) == VIEW_HEADER)
// Inflate HEADER Layout
else if (getItemViewType(position) == VIEW_OPTIONS)
// Inflate Options Layout
else
// Inflate comments Layout
}
// Fill the view contents according to its type
....
return convertView;
}
}
Android will re-use the views. However Android will re-use views of the same type always.