In android development, different listview are linked at the same time. androidlistview
When creating an Android program, you need to display two different listview items on one screen and start to use <linearlayout> to wrap the two listview items during <ScrollView> setting,
There is a problem that cannot be linked at the same time.
One of the listview is that I need to bind data to this image,
Ignore binding content !!!
Later, we realized that we needed to set the height of each listview and bind it to the View to achieve simultaneous interaction.
1 public void SetListViewHeight (ListView listView) {2 ListAdapter List_Adapter = listView. getAdapter (); 3 if (List_Adapter = null) {4 return; 5} 6 int ALLHeight = 0; 7 for (int I = 0; I <List_Adapter.getCount (); I ++) {8 View listItem = List_Adapter.getView (I, null, listView); 9 listItem. measure (0, 0); // you cannot obtain the View width before creating a View. Before that, we must select measure. 10 ALLHeight + = listItem. getMeasuredHeight (); 11} 12 ViewGroup. layoutParams params = listView. getLayoutParams (); 13 params. height = ALLHeight + (listView. getDividerHeight () * (List_Adapter.getCount ()-1); // listView. getDividerHeight () is used to obtain the height occupied by separators between subitems: 14 15 // params. height: the height of the entire ListView is 16 listView. setLayoutParams (params); 17}
Call the "SetListViewHeight (listview ListView)" function next to the listView to realize simultaneous interaction between two or more different listview views.