Example usage for android.widget AbsListView setChoiceMode

List of usage examples for android.widget AbsListView setChoiceMode

Introduction

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

Prototype

public void setChoiceMode(int choiceMode) 

Source Link

Document

Defines the choice behavior for the List.

Usage

From source file:it.gulch.linuxday.android.widgets.BookmarksMultiChoiceModeListener.java

public static void register(AbsListView listView, BookmarkManager bookmarkManager) {
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    BookmarksMultiChoiceModeListener listener = new BookmarksMultiChoiceModeListener(listView, bookmarkManager);
    listView.setMultiChoiceModeListener(listener);
}

From source file:net.lp.actionbarpoirot.helpers.FragmentHelperHoneycomb.java

protected void configureViewGroupContextMenu(AbsListView viewGroup, boolean multiChoiceMode) {
    mAdapter = viewGroup;//from   w  w w  .  ja v  a2  s  . c o m
    viewGroup.setOnItemLongClickListener(this);
    if (multiChoiceMode) {
        ensureMultiChoiceModeUser();

        viewGroup.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
        viewGroup.setMultiChoiceModeListener(this);
    } else {
        viewGroup.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    }
}

From source file:net.sf.diningout.app.ui.RestaurantActivity.java

@Override
public void onViewCreated(AbsListView view) {
    int padding = view.getPaddingTop();
    view.setPadding(padding, Themes.getActionBarSize(this) + padding, padding, padding);
    view.setClipToPadding(false);/*from  ww w .  j  a v a 2s  .c  om*/
    view.setChoiceMode(CHOICE_MODE_SINGLE);
    ((RestaurantCursorAdapter) view.getAdapter()).setSelectedId(mId);
}

From source file:com.gigathinking.simpleapplock.AppListFragment.java

@Override
public void onStart() {
    super.onStart();

    if (!noAds) {
        final AdView adView = (AdView) getActivity().findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice("YOUR DEVICE 1")
                .addTestDevice("YOUR DEVICE 2").build();
        adView.loadAd(adRequest);/*from  w  ww  .  java2s  .c  o  m*/
        adView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.id_ll_app_list);
                ll.findViewById(R.id.adView).setVisibility(View.VISIBLE);
            }
        });
    } else {
        (getActivity().findViewById(R.id.adView)).setVisibility(View.GONE);
    }

    interstitial = new InterstitialAd(getActivity());
    interstitial.setAdUnitId("YOUR AD UNIT ID");
    interstitial.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            mPrefs.edit().putInt("ad_count", (mPrefs.getInt("ad_count", 0) + 1)).commit();
        }
    });

    // Create ad request.
    AdRequest adRequestInterestial = new AdRequest.Builder().addTestDevice("YOUR DEVICE 1")
            .addTestDevice("YOUR DEVICE 2").build();

    // Begin loading your interstitial.
    if (!noAds) {
        interstitial.loadAd(adRequestInterestial);
    }

    if (!mList.isEmpty()) {
        showInitialStart(false);
    } else {
        showInitialStart(true);
    }
    AbsListView listView = (AbsListView) getActivity().findViewById(R.id.lv_app_list);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(this);
    mAdapter = new AppListAdapter(getActivity(), R.layout.layout_applist_item, mList);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (isAdded()) {
                startActivityForResult(new Intent(context, AppPicker.class), 22);
            }
        }
    };
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver,
            new IntentFilter(AppLockApplication.LAUNCH_PICKER));

    //Limit 5 interstitial ads per day.
    int today = Integer.parseInt(DateFormat.format("d", Calendar.getInstance()).toString());
    if (mPrefs.getInt("today", 0) != today) {
        mPrefs.edit().putInt("ad_count", 0).commit();
        mPrefs.edit().putInt("today", today).commit();
    }
}

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

public static void clearListViewChoices(final AbsListView view) {
    if (view == null)
        return;//from  w  w w  .ja  v a 2 s . co 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;/* ww  w .j  a  va  2 s.co 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);
}