I'm working on a program that shows the image.
This is a ListView and GridView wrapped in ScrollView. The program works as follows: when you click on GridView item, selected item is added to the ListView, thus it is possible to add several items into the ListView. Consequently, it is possible to scroll through the entire contents of ScrollView. Everything works fine until ListView contains a large amount of data, in this case adding and rendering of the new ListView will slow down significantly. Therefore, I would like to ask if anyone dealt with similar problem and knows better way to resize and redraw the entire ListView.
Currently I perform the calculation and adjust the size of ListView as follows:
public ListUtils(ListView listView){
ListAdapter adapter = listView.getAdapter();
int count = adapter.getCount();
int itemsHeight;
View oneChild = listView.getChildAt(0);
if( oneChild == null){
return;
}
itemsHeight = oneChild.getHeight();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)listView.getLayoutParams();
params.height = (itemsHeight * count);
listView.setLayoutParams(params);
}