0

Is it possible to add separator view to listview without changing adapter's list of items?

I know that you can inflate different types of items with different layouts but that's not what i'm looking for. I dont want to change list of items which adapter uses. Only want to add separator at desired position.

Something similar to ListView#AddHeader. It adds view at the top of the list but doesn't change list of items.

I want to add view between two items, but don't want to change list of items.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
user3199693
  • 128
  • 4
  • 12
  • No way the only way is by the customadapter check this post : http://javatechig.com/android/listview-with-section-header-in-android – TooCool Oct 03 '14 at 14:55
  • you need one seprator below of list? in your question you said "I want seprator between two items" and in below answer's comment you said "No because I dont want divider between every two items." which one is true? – MHP Oct 03 '14 at 15:37
  • @Abdellah That code on that link changes adapter's list of items. It adds separators in the list of items. I dont want separator to be part of the items list. – user3199693 Oct 03 '14 at 16:15
  • @MHP as I said below. I only want to have one separator in the list. Not between every two items. I want to have only one. Let's say only between 5th and 6th item. (Numbers are arbitrary) – user3199693 Oct 03 '14 at 16:17
  • As i said No way without using CustomAdapter to did it, but you can ask android google developer to add this feature – TooCool Oct 03 '14 at 16:22

1 Answers1

1

Is this what you're looking for? dividerHeight property.

<ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="5dp"
        android:dividerHeight="2dp" >
NightwareSystems
  • 433
  • 5
  • 17
  • No because I dont want divider between every two items. I want to have list of let's say 10 items, and only one separator. – user3199693 Oct 03 '14 at 14:43
  • Then maybe what you're looking for is ExpandableListView, check this out (Sorry just a quickly googled link): http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/ – NightwareSystems Oct 03 '14 at 14:48
  • Is it possible to make items always expanded in ExpendableListView? – user3199693 Oct 03 '14 at 16:19
  • You can loop your groups and call expand(groupPosition), if you want it to be expanded by default without going through the hassle each time, then extend the class and override the getGroupView method. See this answer, should give you a hint: http://stackoverflow.com/questions/3988337/how-to-keep-expandablelistview-in-expanded-status – NightwareSystems Oct 03 '14 at 16:27
  • Pay attention to the comment by nerith in the same link, in case you're adding the groups dynamically. – NightwareSystems Oct 03 '14 at 16:29