类android.widget.AdapterView.OnItemLongClickListener源码实例Demo

下面列出了怎么用android.widget.AdapterView.OnItemLongClickListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spidey   文件: ScansActivity.java
@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);
     
}
 
源代码2 项目: iSCAU-Android   文件: CaldroidFragment.java
/**
 * 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;
}
 
源代码3 项目: bitmask_android   文件: LogFragment.java
@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;
        }
    });
}
 
源代码4 项目: CameraV   文件: UserManagementFragment.java
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);
}
 
源代码5 项目: CSipSimple   文件: CallLogListFragment.java
@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;
        }
    });
}
 
源代码6 项目: AndroidBottomSheet   文件: BottomSheet.java
/**
 * 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;
        }

    };
}
 
源代码7 项目: droitatedDB   文件: NotesActivity.java
@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;
		}
	});
}
 
源代码8 项目: androidtestdebug   文件: TitlesFragment.java
@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);
 }
 
源代码9 项目: androidtestdebug   文件: TitlesFragment.java
@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);
}
 
源代码10 项目: androidtestdebug   文件: TitlesFragment.java
@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);
}
 
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;
		}
	});
}
 
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;
		}
	});
}
 
@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;
		}
	});
}
 
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;
		}
	});
}
 
源代码15 项目: CameraV   文件: UserManagementFragment.java
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);
}
 
源代码16 项目: Swface   文件: StickyListHeadersListView.java
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
源代码17 项目: o2oa   文件: StickyListHeadersListView.java
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
源代码18 项目: o2oa   文件: StickyGridHeadersGridView.java
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
    mList.setOnItemLongClickListener(listener);
}
 
源代码20 项目: iSCAU-Android   文件: DateGridFragment.java
public OnItemLongClickListener getOnItemLongClickListener() {
	return onItemLongClickListener;
}
 
源代码21 项目: iSCAU-Android   文件: DateGridFragment.java
public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) {
	this.onItemLongClickListener = onItemLongClickListener;
}
 
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
源代码24 项目: UltimateAndroid   文件: DraggableGridViewPager.java
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
@Override
public void setOnItemLongClickListener(
        OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
源代码26 项目: UltimateAndroid   文件: DraggableGridViewPager.java
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
	mOnItemLongClickListener = listener;
}
 
@Override
public void setOnItemLongClickListener(
        android.widget.AdapterView.OnItemLongClickListener listener) {
    this.mOnItemLongClickListener = listener;
    super.setOnItemLongClickListener(this);
}
 
源代码28 项目: AndroidBottomSheet   文件: BottomSheet.java
/**
 * 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
 * @return The builder, the method has been called upon, as an instance of the class {@link
 * Builder}
 */
public final Builder setOnItemLongClickListener(
        @Nullable final OnItemLongClickListener listener) {
    bottomSheet.setOnItemLongClickListener(listener);
    return this;
}
 
源代码29 项目: AndroidBottomSheet   文件: BottomSheet.java
/**
 * 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;
}
 
源代码30 项目: AndroidMaterialValidation   文件: Spinner.java
/**
 * 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);
}
 
 类所在包
 类方法
 同包方法