android-inherit baseadapter--self-defined adapter, GetView run multiple times with workaround

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.