in Android

How to add divider in ListView

In order for this code snippet to work, you must add item names starting with “-” where you want to add a divider.

public View getView(int position, View convertView, ViewGroup parent) {
 
        if(items.get(position).get("name").startsWith("-")){
                View divider = mInflater.inflate(R.layout.progressbar, null);
                return divider;
        }
//Implement the rest of the getView here
}
Share