Define a ListView layout that runs multiple times GetView:
<listview android:id= "@+id/lv_messages" android:layout_width= "match_parent" android:layout_ height= "Match_parent" android:layout_alignparentleft= "true" android:layout_below= "@+id/linearlayout1" android:cachecolorhint= "#0000" android:divider= "#0000" android:dividerheight= "2DP" android: Listselector= "#0000" > </ListView>
Run several times because each view is displayed, it is measured to the height of the view. Run the measure method. Causes GetView to run multiple times.
The correct layout:
<listview android:id= "@+id/lv_messages" android:layout_width= "fill_parent" android:layout_ height= "Fill_parent" android:layout_alignparentleft= "true" android:layout_below= "@+id/linearlayout1" android:cachecolorhint= "#0000" android:divider= "#0000" android:dividerheight= "2DP" android: Listselector= "#0000" > </ListView>
The width and height are set to fill_parent, assuming that the ListView has a parent layout, also the width and height of the parent layout is set to Fill_parent, which successfully overcomes the problem of defining the adapter GetView run multiple times.
The following 3 lines solve the problem of the ListView sliding to Black:
Android:cachecolorhint= "#0000" android:divider= "#0000"
Hope to help everyone to solve this problem!
android-inherit baseadapter--self-defined adapter, GetView run multiple times with workaround