How to give space or background or divider between list view for one row in android.I have implemented onitem click in list view.if user click background or space or divider the how to avoid click event for backgroud?.can anybody tell how to do? Thanks
Asked
Active
Viewed 775 times
0
-
This question is weirdly worded. What do you mean by space between `ListView` row? Between it vertically? – Andy Jun 30 '12 at 07:20
-
2Use android:divider property. – RobinHood Jun 30 '12 at 07:23
1 Answers
0
use Android ListView Divider
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cashItemsList"
android:cacheColorHint="#00000000"
android:divider="@drawable/list_divider" android:dividerHeight="1dp"></ListView>
or
Created res/drawable/divider.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#ffcdcdcd" android:endColor="#ffcdcdcd" android:angle="270.0" />
</shape>
And in styles.xml for listview item, I added the following lines:
<item name="android:divider">@drawable/divider</item>
<item name="android:dividerHeight">1dp</item>

Community
- 1
- 1

Dheeresh Singh
- 15,643
- 3
- 38
- 36
-
-
ok if there is 10 rows then you only need it (space) for 3rd row like ? – Dheeresh Singh Jun 30 '12 at 07:50
-
-
so you can do that in get view just add the padding if row 3rd ..... need to handle more if you are using convert view – Dheeresh Singh Jun 30 '12 at 08:05