android.widget.AdapterView.OnItemLongClickListener Java Examples

The following examples show how to use android.widget.AdapterView.OnItemLongClickListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserManagementFragment.java    From CameraV with GNU General Public License v3.0 6 votes vote down vote up
private void initOrganizations()
{
	listOrganizations = informaCam.installedOrganizations.listOrganizations();

	organizationsHolder.setOnItemLongClickListener(new OnItemLongClickListener()
	{

		@Override
		public boolean onItemLongClick(AdapterView<?> adapterView, View view, int viewId, long l)
		{
			IOrganization org = listOrganizations.get((int) l);
			((HomeActivityListener) a).getContextualMenuFor(org);

			return true;
		}
	});

	listOrganizationsAdapter = new OrganizationsListAdapter(listOrganizations);
	organizationsHolder.setAdapter(listOrganizationsAdapter);
}
 
Example #2
Source File: LogFragment.java    From bitmask_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                                       int position, long id) {
            ClipboardManager clipboard = (ClipboardManager)
                    getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Log Entry", ((TextView) view).getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), R.string.copied_entry, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
 
Example #3
Source File: ScansActivity.java    From spidey with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setTitle(R.string.history_of_spidey_scans);
    
    mDb = DatabaseHelper.getInstance(this);
    List<Scan> scans = mDb.getAllScans();

    mListView = getListView();
    
    //add on long click listener to start action mode
    getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            onListItemCheck(position);
            return true;
        }
    });
    
 // use the SimpleCursorAdapter to show the
    // elements in a ListView
    ScanAdapter adapter = new ScanAdapter(this,scans);
    setListAdapter(adapter);
     
}
 
Example #4
Source File: CaldroidFragment.java    From iSCAU-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Callback to listener when date is valid (not disable, not outside of
 * min/max date)
 * 
 * @return
 */
private OnItemLongClickListener getDateItemLongClickListener() {
	dateItemLongClickListener = new OnItemLongClickListener() {
		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view,
				int position, long id) {

			DateTime dateTime = dateInMonthsList.get(position);

			if (caldroidListener != null) {
				if ((minDateTime != null && dateTime.lt(minDateTime))
						|| (maxDateTime != null && dateTime.gt(maxDateTime))
						|| (disableDates != null && disableDates
								.indexOf(dateTime) != -1)) {
					return false;
				}
				Date date = CalendarHelper.convertDateTimeToDate(dateTime);
				caldroidListener.onLongClickDate(date, view);
			}

			return true;
		}
	};

	return dateItemLongClickListener;
}
 
Example #5
Source File: CallLogListFragment.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
    
    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
 
Example #6
Source File: UserManagementFragment.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
private void initNotifications() {
	listNotifications = informaCam.notificationsManifest.sortBy(Models.INotificationManifest.Sort.COMPLETED);
	notificationsHolder.setOnItemLongClickListener(new OnItemLongClickListener() {


		@Override
		public boolean onItemLongClick(AdapterView<?> adapterView, View view, int viewId, long l)
		{
			INotification notification = informaCam.notificationsManifest.notifications.get((int) l);
			((HomeActivityListener) a).getContextualMenuFor(notification);

			return true;
		}

	});

	listNotificationsAdapter = new NotificationsListAdapter(listNotifications);
	notificationsHolder.setAdapter(listNotificationsAdapter);

	if (listNotifications != null && listNotifications.size() > 0)
	{
		notificationsNoNotifications.setVisibility(View.GONE);
		return;
	}

	notificationsNoNotifications.setVisibility(View.VISIBLE);
}
 
Example #7
Source File: MyListActivityActionbar.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	setContentView(R.layout.main);
	String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
			"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
			"Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
			"OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" };

	MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, values);
	setListAdapter(adapter);

	getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view,
				int position, long id) {

			if (mActionMode != null) {
				return false;
			}
			selectedItem = position;

			// Start the CAB using the ActionMode.Callback defined above
			mActionMode = MyListActivityActionbar.this
					.startActionMode(mActionModeCallback);
			view.setSelected(true);
			return true;
		}
	});
}
 
Example #8
Source File: MyListActivityActionbar.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	String[] values = new String[] { "Android", 
			"iPhone", "WindowsMobile", 
			"Blackberry", "WebOS", "Ubuntu",
			"Windows7", "Max OS X", "Linux", "OS/2", 
			"Ubuntu", "Windows7", "Max OS X", 
			"Linux", "OS/2", "Ubuntu",
			"Windows7", "Max OS X", 
			"Linux", "OS/2" };

	MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, values);
	setListAdapter(adapter);

	getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

			if (mActionMode != null) {
				return false;
			}
			selectedItem = position;

			// Start the CAB using the ActionMode.Callback defined above
			MyListActivityActionbar.this.startActionMode(MyListActivityActionbar.this);
			view.setSelected(true);
			return true;
		}
	});
}
 
Example #9
Source File: MyListActivityActionbar.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	setContentView(R.layout.main);
	String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
			"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
			"Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
			"OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" };

	MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, values);
	setListAdapter(adapter);

	getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view,
				int position, long id) {

			if (mActionMode != null) {
				return false;
			}
			selectedItem = position;

			// Start the CAB using the ActionMode.Callback defined above
			mActionMode = MyListActivityActionbar.this
					.startActionMode(mActionModeCallback);
			view.setSelected(true);
			return true;
		}
	});
}
 
Example #10
Source File: MyListActivityActionbar.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
			"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
			"Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
			"OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" };

	MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, values);
	setListAdapter(adapter);

	getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

		@Override
		public boolean onItemLongClick(AdapterView<?> parent, View view,
				int position, long id) {

			if (mActionMode != null) {
				return false;
			}
			selectedItem = position;

			// TODO Start the CAB using the ActionMode.Callback defined
			// above

			view.setSelected(true);
			return true;
		}
	});
}
 
Example #11
Source File: TitlesFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //Current position should survive screen rotations.
    if (savedInstanceState != null) {
        mCategory = savedInstanceState.getInt("category");
        mCurPosition = savedInstanceState.getInt("listPosition");
    }

    populateTitles(mCategory);
    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final String title = (String) ((TextView) v).getText();

            // Set up clip data with the category||entry_id format.
            final String textData = String.format("%d||%d", mCategory, pos);
            ClipData data = ClipData.newPlainText(title, textData);
            v.startDrag(data, new MyDragShadowBuilder(v), null, 0);
            return true;
        }
    });

    selectPosition(mCurPosition);
}
 
Example #12
Source File: TitlesFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //Current position should survive screen rotations.
    if (savedInstanceState != null) {
        mCategory = savedInstanceState.getInt("category");
        mCurPosition = savedInstanceState.getInt("listPosition");
    }

    populateTitles(mCategory);
    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final String title = (String) ((TextView) v).getText();

            // Set up clip data with the category||entry_id format.
            final String textData = String.format("%d||%d", mCategory, pos);
            ClipData data = ClipData.newPlainText(title, textData);
            v.startDrag(data, new MyDragShadowBuilder(v), null, 0);
            return true;
        }
    });

    selectPosition(mCurPosition);
}
 
Example #13
Source File: TitlesFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
 public void onActivityCreated(Bundle savedInstanceState) {
     super.onActivityCreated(savedInstanceState);

     //Current position should survive screen rotations.
     if (savedInstanceState != null) {
         mCategory = savedInstanceState.getInt("category");
         mCurPosition = savedInstanceState.getInt("listPosition");
     }

     populateTitles(mCategory);
     ListView lv = getListView();
     lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
     lv.setCacheColorHint(Color.TRANSPARENT);
     lv.setOnItemLongClickListener(new OnItemLongClickListener() {
         @SuppressLint("DefaultLocale")
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
             final String title = (String) ((TextView) v).getText();

             // Set up clip data with the category||entry_id format.
             final String textData = String.format("%d||%d", mCategory, pos);
             ClipData data = ClipData.newPlainText(title, textData);
             v.startDrag(data, new MyDragShadowBuilder(v), null, 0);
             return true;
         }
     });

     selectPosition(mCurPosition);
 }
 
Example #14
Source File: BottomSheet.java    From AndroidBottomSheet with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns a listener, which allows to observe when the items of a bottom sheet have
 * been long-clicked.
 *
 * @return The listener, which has been created, as an instance of the type {qlink
 * OnItemLongClickListener}
 */
private OnItemLongClickListener createItemLongClickListener() {
    return new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view,
                                       final int position, final long id) {

            if (!rootView.isDragging() && !rootView.isAnimationRunning() &&
                    itemLongClickListener != null) {
                int index = position;

                if (adapter.containsDividers()) {
                    for (int i = position; i >= 0; i--) {
                        if (adapter.getItem(i) == null ||
                                (adapter.getItem(i) instanceof Divider &&
                                        i % adapter.getColumnCount() > 0)) {
                            index--;
                        }
                    }
                }

                return itemLongClickListener
                        .onItemLongClick(parent, view, index, getId(position));
            }

            return false;
        }

    };
}
 
Example #15
Source File: NotesActivity.java    From droitatedDB with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	noteCursorAdapter = new NoteCursorAdapter(this);

	setListAdapter(noteCursorAdapter);

	loaderCallback = new NoteLoaderCallback(this, noteCursorAdapter, NOTE_LOADER_ID);
	getLoaderManager().initLoader(NOTE_LOADER_ID, null, loaderCallback);

	getListView().setFastScrollEnabled(true);
	getListView().setLongClickable(true);
	getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
		@Override
		public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int postition, final long id) {
			Cursor cursor = (Cursor) noteCursorAdapter.getItem(postition);
			int noteId = cursor.getInt(DB.NoteTable._ID.columnIndex());
			if (noteService.delete(noteId)) {
				getLoaderManager().getLoader(NOTE_LOADER_ID).forceLoad();
				Toast.makeText(NotesActivity.this, R.string.delete_success, Toast.LENGTH_LONG).show();
			} else {
				Toast.makeText(NotesActivity.this, R.string.delete_fail, Toast.LENGTH_LONG).show();
			}
			return true;
		}
	});
}
 
Example #16
Source File: DateGridFragment.java    From iSCAU-Android with GNU General Public License v3.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) {
	this.onItemLongClickListener = onItemLongClickListener;
}
 
Example #17
Source File: StickyListHeadersListView.java    From Swface with Apache License 2.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
Example #18
Source File: StickyListHeadersListView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
Example #19
Source File: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
Example #20
Source File: StickyListHeadersListView.java    From StickyListHeadersWithRefreshAndLoadMore with Apache License 2.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
Example #21
Source File: StickyGridHeadersGridView.java    From StickyGridHeaders with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemLongClickListener(
        android.widget.AdapterView.OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
Example #22
Source File: DraggableGridViewPager.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
Example #23
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
Example #24
Source File: DraggableGridViewPager.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
Example #25
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
Example #26
Source File: DraggableGridViewPager.java    From Android-DraggableGridViewPager with MIT License 4 votes vote down vote up
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
Example #27
Source File: DateGridFragment.java    From iSCAU-Android with GNU General Public License v3.0 4 votes vote down vote up
public OnItemLongClickListener getOnItemLongClickListener() {
	return onItemLongClickListener;
}
 
Example #28
Source File: Spinner.java    From AndroidMaterialValidation with Apache License 2.0 2 votes vote down vote up
/**
 * @return The callback to be invoked with an item in this AdapterView has been clicked and
 * held, or null id no callback as been set.
 */
public final OnItemLongClickListener getOnItemLongClickListener() {
    return getView().getOnItemLongClickListener();
}
 
Example #29
Source File: Spinner.java    From AndroidMaterialValidation with Apache License 2.0 2 votes vote down vote up
/**
 * Register a callback to be invoked when an item in this AdapterView has been clicked and held
 *
 * @param listener
 *         The callback that will run
 */
public final void setOnItemLongClickListener(final OnItemLongClickListener listener) {
    getView().setOnItemLongClickListener(listener);
}
 
Example #30
Source File: BottomSheet.java    From AndroidBottomSheet with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the listener, which should be notified, when an item of the bottom sheet has been
 * long-clicked.
 *
 * @param listener
 *         The listener, which should be set, as an instance of the type {@link
 *         OnItemLongClickListener} or null, if no listener should be notified
 */
public final void setOnItemLongClickListener(@Nullable final OnItemLongClickListener listener) {
    this.itemLongClickListener = listener;
}