Example usage for android.widget AbsListView clearChoices

List of usage examples for android.widget AbsListView clearChoices

Introduction

In this page you can find the example usage for android.widget AbsListView clearChoices.

Prototype

public void clearChoices() 

Source Link

Document

Clear any choices previously set

Usage

From source file:de.vanita5.twittnuker.util.Utils.java

public static void clearListViewChoices(final AbsListView view) {
    if (view == null)
        return;/*from  ww w.ja  va 2s. c  o m*/
    final ListAdapter adapter = view.getAdapter();
    if (adapter == null)
        return;
    view.clearChoices();
    view.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    // Workaround for Android bug
    // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
    final int position = view.getFirstVisiblePosition(), offset = Utils.getFirstChildOffset(view);
    view.setAdapter(adapter);
    Utils.scrollListToPosition(view, position, offset);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void clearListViewChoices(final AbsListView view) {
    if (view == null)
        return;/*from  w  w w.ja  v  a 2s  . c  o m*/
    final ListAdapter adapter = view.getAdapter();
    if (adapter == null)
        return;
    view.clearChoices();
    for (int i = 0, j = view.getChildCount(); i < j; i++) {
        view.setItemChecked(i, false);
    }
    view.post(new Runnable() {
        @Override
        public void run() {
            view.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
        }
    });
    // Workaround for Android bug
    // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
    //        final int position = view.getFirstVisiblePosition(), offset = Utils.getFirstChildOffset(view);
    //        view.setAdapter(adapter);
    //        Utils.scrollListToPosition(view, position, offset);
}