Android ListView Multiple Refresh repeat execution GetView solution _android

Source: Internet
Author: User
I've never noticed before. ListView's GetView will repeat several times, this time because the layout is more complex, so in the test time to breakpoint tracking, found that the same data repeatedly executed. Feel very strange, so the internet search a bit. The interpretation of the network is basically consistent, that is ListView layout when the height and width are not fill_parent, resulting in constant calculation of the height, constantly refreshed. Or that its parent container is not set to Fill_parent.

Can be too complicated layout, all according to Fill_parent to adjust unrealistic. So think of another option, that is, dynamic fixed height.
After the program is run, fix the height of the ListView, and then initialize the item information.
Copy Code code as follows:

private void Fixedlistview () {
ListView = (ListView) Findviewbyid (R.id.listview);
Viewgroup.layoutparams params = Listview.getlayoutparams ();
Layout = (Horizontalscrollview) Findviewbyid (r.id.layout);
Params.height = Layout.getheight (); Need to set the height of the ListView, you can set to a fixed value, can also be set to the height of other containers, if the height of other containers, then do not perform in oncreate, need to do delay processing, or height of 0
Listview.setlayoutparams (params);
}

This shows that the speed of ListView refresh is greatly accelerated. Colleagues also solved the item in Chinese this input edittext if there is a Addtextchangedlistener (new Textwatcher () listening, resulting in multiple execution of the listening code.
Related Article

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.