Android Open Source - sdl_tester_android Multiple List View Dialog

From Project

Back to project page sdl_tester_android.


The source code is released under:

Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

If you think the Android project sdl_tester_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.livio.sdl.dialogs;
//from w ww.  ja v  a2s  .c  o m
import java.util.List;

import android.content.Context;
import android.content.DialogInterface;
import android.widget.ListAdapter;
 * A generic class representing a ListView dialog that allows the user to select
 * multiple listview items.  Selected items are stored in a protected List<E> object
 * called selectedItems, which can be used by subclasses of this class.
 * @author Mike Burke
 * @param <E>
public class MultipleListViewDialog<E> extends BaseMultipleListViewDialog<E> {

  public MultipleListViewDialog(Context context, String title, List<E> items) {
    super(context, title, items);

  public MultipleListViewDialog(Context context, String title, List<E> items, List<E> checkedItems) {
    super(context, title, items);
    if(checkedItems != null && checkedItems.size() > 0){
    if(selectedItems != null && selectedItems.size() > 0){
      // TODO: make this more efficient, but should be good enough for small data sets
      ListAdapter adapter = listView.getAdapter();
      int adapterLen = adapter.getCount();
      int selectedLen = selectedItems.size();
      for(int i=0; i<adapterLen; i++){
        for(int j=0; j<selectedLen; j++){
            listView.setItemChecked(i, true);
  //dialog button listeners
  private final DialogInterface.OnClickListener positiveButton = new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {


Java Source Code List