How to add divider items to ListView

SDK Version: 

Today I'm going to show an easy way to add divider items to your ListView.
First off, you need your own ListView Adapter which extends SimpleAdapter. If you don't know how to create a new class for your own SimpleAdapter, please go and visit:

Ok, so here's how it looks like:

  1. public class SpecialAdapter extends SimpleAdapter {
  2.         private LayoutInflater mInflater;
  3.         private List<HashMap<String, String>> items;
  5.         public SpecialAdapter(Context context, List<HashMap<String, String>> items, int resource, String[] from, int[] to) {
  6.                 super(context, items, resource, from, to);
  7.                 // Cache the LayoutInflate to avoid asking for a new one each time.
  8.         this.items = items;
  9.         }
  11.          @Override
  12.      public boolean areAllItemsEnabled() {
  13.          return false;
  14.      }
  16.      @Override
  17.      public boolean isEnabled(int position) {
  18.          boolean enabled = false;

Syndicate content