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)