Making a view in a ListView invisible Android

Source: Internet
Author: User

Problem:

I have a, that ListView ' s using a custom adapter. I want to dynamically add/remove items from the ListView . I ' ve tried everything inside the getView() method in my view adapter. I ' ve tried doing on the setVisiblity(View.GONE) view I ' m returning. And it in fact doesn ' t draw the view, but it still allocates space for the view and it ' s just a blank black space.

Is this even possible to set items in ListView invisible?

Reply:

You need to call Setvisiblity (View.gone) on the returned View and all of the views inside it. If You is reusing the convert view passed in you need to remember to call Setvisiblity (view.visible) on all the views you Want visible.

If you had a lot of invisible views, need to set the divider height to 0 and add your own divider to the returned Views. Otherwise the ' invisible ' views would each has a visible divider and produce a noticeable gray line between visible views.

Conclusion:

1) Set the view control to not be seen.

2) The control settings inside the view are not visible.

3) in the XML layout file, set the ListView divider height to 0, using a custom separator bar.

4) Set the divider bar inside the view to not be visible.

5) The first line of the separator bar is not considered.

Making a view in a ListView invisible Android

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.