android--resolving problems that the ListView Footerdivider does not display (solution)

Source: Internet
Author: User

For many Android developers, the divider of the ListView is a headache, because the ListView is enabled by default Footerdivider (that is, android:footerdividersenabled= " True "), but why doesn't it actually show footerdivider? The answer is simple: because your footerview is normally empty (null). When the Footerview is empty, Footerdivider is not displayed.

Then we have to Footerview in the empty time, also want to show footerdivider, what should be done? Please see below.

The solution is as follows:

Step one, set the ListView to not enable Footerdivider, that is, set android:footerdividersenabled= "false".

Step two, the divider drawable file in the form of a view into the Footview can be.

For example, my divider's drawable file is named Bg_border.png:

First, write a layout file such as View_border.xml:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" match_parent "    android:layout_height=" 1DP "   android:orientation=" Vertical "     >     <view          android:layout_width=" match_parent "         android:layout_height=" 1DP "         android:background= "@drawable/bg_border"         /></linearlayout>
Second, after the ListView is initialized, the layout file is added to the Footview before binding the data:

List.addfooterview (Layoutinflater.from (usercreditinfoactivity.this). Inflate (R.layout.view_border, null));

Then bind the data to see the effect.

Note The first step, android:footerdividersenabled= "false".


This article is finished, reprint please indicate the source, thank you for watching.

android--resolving problems that the ListView Footerdivider does not display (solution)

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.