user386430
user386430

Reputation: 4967

How to remove divider for one row in custom list view in android

Can anybody tell me to remove the divider between rows in Android? I want to remove the third row divider in a custom List View.

Upvotes: 4

Views: 6072

Answers (3)

Bondax
Bondax

Reputation: 3163

Edit your item layout to contain a Textview with a fixed height for the divider and spans over the full width, but is set to visibility=View.GONE. Then, only show those dividers that you want to show (by setting visibility = GONE or VISIBLE). If you wrap that layout with a custom view, this can be very comfortable in use. This way you don't interfere with some inner logic in your adapter/listview and you use direct mechanisms instead of building your layout on side effects.

Upvotes: 0

sunil
sunil

Reputation: 6614

have you seen this post how to change color of Android ListView Seperator line?

  • make a custom list adaptor. a good example is here android-amazing-listview
  • in overridden getView method when position is 3 , do below processes
  • by this way you can change the border color and width.
  • make it same as the background color, so that it appears as borderless
  • List item

Upvotes: 0

MRD
MRD

Reputation: 7184

That would not be possible from the ListView properties.

The alternative is to implement the divider in each row using a custom adapter and hide it when the index is 3 from the method:

public View getView(int position, View convertView, ViewGroup parent)

Upvotes: 1

Related Questions