public boolean onLongClick ( int index , boolean selectItem ) { if ( mLastLongPressIndex == null ) { // we only consider long presses on not selected items if ( mFastAdapter . getAdapterItem ( index ) . isSelectable ( ) ) { mLastLongPressIndex = index ; // we select this item as well if ( selectItem ) mFastAdapter . select ( index ) ; if ( mActionModeHelper != null ) mActionModeHelper . checkActionMode ( null ) ; // works with null as well, as the ActionMode is active for sure! return true ; } } else if ( mLastLongPressIndex != index ) { // select all items in the range between the two long clicks selectRange ( mLastLongPressIndex , index , true ) ; // reset the index mLastLongPressIndex = null ; } return false ; }
will take care to save the long pressed index or to select all items in the range between the current long pressed item and the last long pressed item