List of usage examples for android.widget ListView isItemChecked
public boolean isItemChecked(int position)
From source file:com.jaspersoft.android.jaspermobile.dialog.CalendarDayDialogFragment.java
@NonNull @Override//from w ww . java2s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); ListView listView = (ListView) inflater.inflate(mListLayout, null); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); final List<CheckItem> items = createItems(); final Adapter adapter = new Adapter(getActivity(), listView, mMultiChoiceItemLayout, items); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int which, long id) { ListView listView = (ListView) parent; boolean isChecked = listView.isItemChecked(which); if (which == 0) { for (CheckItem item : items) { item.checked = isChecked; } selectedDays.clear(); if (isChecked) { selectedDays.addAll(days); } } else { int index = which - 1; CalendarViewRecurrence.Day item = days.get(index); if (isChecked) { selectedDays.add(item); } else { selectedDays.remove(item); } items.get(which).checked = isChecked; boolean allSelected = selectedDays.containsAll(days); items.get(0).checked = allSelected; } adapter.notifyDataSetChanged(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sr_days); builder.setView(listView); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mDialogListener != null) { ((DaysSelectedListener) mDialogListener).onDaysSelected(selectedDays); } } }); builder.setNegativeButton(R.string.cancel, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.jaspersoft.android.jaspermobile.dialog.CalendarMonthDialogFragment.java
@NonNull @Override//from w w w. ja v a2s .com public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); ListView listView = (ListView) inflater.inflate(mListLayout, null); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); final List<CheckItem> items = createItems(); final Adapter adapter = new Adapter(getActivity(), listView, mMultiChoiceItemLayout, items); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int which, long id) { ListView listView = (ListView) parent; boolean isChecked = listView.isItemChecked(which); if (which == 0) { for (CheckItem item : items) { item.checked = isChecked; } selectedMonths.clear(); if (isChecked) { selectedMonths.addAll(months); } } else { int index = which - 1; CalendarViewRecurrence.Month item = months.get(index); if (isChecked) { selectedMonths.add(item); } else { selectedMonths.remove(item); } items.get(which).checked = isChecked; boolean allSelected = selectedMonths.containsAll(months); items.get(0).checked = allSelected; } adapter.notifyDataSetChanged(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sr_months); builder.setView(listView); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mDialogListener != null) { ((MonthsSelectedListener) mDialogListener).onMonthsSelected(selectedMonths); } } }); builder.setNegativeButton(R.string.cancel, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:org.cvasilak.jboss.mobile.admin.fragments.DeploymentsViewFragment.java
public List<String> getSelectedItems(DialogInterface dialogInterface) { ListView list = ((AlertDialog) dialogInterface).getListView(); List<String> selectedGroups = new ArrayList<String>(); for (int i = 0; i < list.getCount(); i++) { if (list.isItemChecked(i)) selectedGroups.add((String) list.getItemAtPosition(i)); }/*from w w w.j a v a2 s .co m*/ return selectedGroups; }
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { m_swipeList.discardUndo();//www. java 2 s .c om l.setItemChecked(position, l.isItemChecked(position)); showContextActionBarIfNeeded(); }
From source file:nl.mpcjanssen.simpletask.Simpletask.java
private void selectAllTasks() { ListView lv = getListView(); int itemCount = lv.getCount(); for (int i = 0; i < itemCount; i++) { // Only check tasks that are not checked yet // and skip headers // This prevents double counting in the CAB title Task t = getTaskAt(i);/*from w w w . j av a 2 s . co m*/ if (t != null && !lv.isItemChecked(i)) { lv.setItemChecked(i, true); } } }