Java Code Examples for android.view.View#setOnLongClickListener()
The following examples show how to use
android.view.View#setOnLongClickListener() .
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: BaseItemDraggableAdapter.java From JD-Test with Apache License 2.0 | 6 votes |
/** * To bind different types of holder and solve different the bind events * * @param holder * @param positions * @see #getDefItemViewType(int) */ @Override public void onBindViewHolder(K holder, int positions) { super.onBindViewHolder(holder, positions); int viewType = holder.getItemViewType(); if (mItemTouchHelper != null && itemDragEnabled && viewType != LOADING_VIEW && viewType != HEADER_VIEW && viewType != EMPTY_VIEW && viewType != FOOTER_VIEW) { if (mToggleViewId != NO_TOGGLE_VIEW) { View toggleView = ((BaseViewHolder) holder).getView(mToggleViewId); if (toggleView != null) { toggleView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder); if (mDragOnLongPress) { toggleView.setOnLongClickListener(mOnToggleViewLongClickListener); } else { toggleView.setOnTouchListener(mOnToggleViewTouchListener); } } } else { holder.itemView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder); holder.itemView.setOnLongClickListener(mOnToggleViewLongClickListener); } } }
Example 2
Source File: BaseViewHolder.java From demo4Fish with MIT License | 6 votes |
/** * add long click view id * * @param viewId * @return if you use adapter bind listener * @link {(adapter.setOnItemChildLongClickListener(listener))} * <p> * or if you can use recyclerView.addOnItemTouch(listerer) wo also support this menthod */ public BaseViewHolder addOnLongClickListener(final int viewId) { itemChildLongClickViewIds.add(viewId); final View view = getView(viewId); if (view != null) { if (!view.isLongClickable()) { view.setLongClickable(true); } view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (adapter.getmOnItemChildLongClickListener() != null) { return adapter.getmOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition()); } return false; } }); } return this; }
Example 3
Source File: AlbumSongAdapter.java From Musync with MIT License | 6 votes |
public MyViewHolder(View view) { super(view); SongName = (TextView) view.findViewById(R.id.songName); SongPostion = (TextView) view.findViewById(R.id.postionTV); artistName = (TextView) view.findViewById(R.id.artistName); musicIndicator = (Indicator) view.findViewById(R.id.MusicIndicator); songLL = (LinearLayout) view.findViewById(R.id.songLL); totatSongsTV = (TextView) view.findViewById(R.id.totalSongsTextView); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { int pos = getLayoutPosition(); return true; } }); }
Example 4
Source File: MediaEntryViewHolder.java From Phonograph with GNU General Public License v3.0 | 5 votes |
public MediaEntryViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); }
Example 5
Source File: ListenerUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 设置长按事件 * @param activity {@link Activity} * @param onLongClickListener {@link View.OnLongClickListener} * @param viewIds View id 数组 * @return {@code true} success, {@code false} fail */ public static boolean setOnLongClicks(final Activity activity, final View.OnLongClickListener onLongClickListener, @IdRes final int... viewIds) { if (activity != null && onLongClickListener != null && viewIds != null) { for (int i = 0, len = viewIds.length; i < len; i++) { View findView = ViewUtils.findViewById(activity, viewIds[i]); if (findView != null) { findView.setOnLongClickListener(onLongClickListener); } } return true; } return false; }
Example 6
Source File: CustomRecycleViewAdapter.java From libcommon with Apache License 2.0 | 5 votes |
@NonNull @Override public ViewHolder<T> onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { final LayoutInflater inflater = getLayoutInflater(parent.getContext()); final View view = onCreateItemView(inflater, parent, viewType); view.setOnClickListener(mOnClickListener); view.setOnLongClickListener(mOnLongClickListener); return onCreateViewHolder(view); }
Example 7
Source File: WeaponExpandableListBowgunAdapter.java From MonsterHunter4UDatabase with MIT License | 5 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v; RecyclerView.ViewHolder viewHolder; int resource = R.layout.fragment_weapon_tree_item_bowgun; v = LayoutInflater.from(parent.getContext()) .inflate(resource, parent, false); viewHolder = new WeaponBowgunViewHolder(v); v.setOnLongClickListener(mListener); return viewHolder; }
Example 8
Source File: NetworkInspectorView.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
ViewHolder(View itemView) { super(itemView); bodyView = (TextView) itemView.findViewById(R.id.body); typeView = (TextView) itemView.findViewById(R.id.type); titleView = (TextView) itemView.findViewById(R.id.title); descView = (TextView) itemView.findViewById(R.id.desc); timestampView = (TextView) itemView.findViewById(R.id.timestamp); line = itemView.findViewById(R.id.line); itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (mCurMessage != null) { try { if (mCurMessage.type != null && mCurMessage.type.equalsIgnoreCase(NetworkEventSender.TYPE_REQUEST)) { if (!TextUtils.isEmpty(mCurMessage.title)) { SDKUtils.copyToClipboard(v.getContext(), mCurMessage.title, true); } } else if (mCurMessage.type != null && mCurMessage.type.equalsIgnoreCase(NetworkEventSender.TYPE_RESPONSE)) { if (!TextUtils.isEmpty(mCurMessage.body)) { SDKUtils.copyToClipboard(v.getContext(), mCurMessage.body, true); } } } catch (Exception e) { e.printStackTrace(); } } return true; } }); }
Example 9
Source File: TodoAdapter.java From stitch-android-sdk with Apache License 2.0 | 5 votes |
TodoItemViewHolder(final View view) { super(view); taskTextView = view.findViewById(R.id.tv_task); taskCheckbox = view.findViewById(R.id.cb_todo_checkbox); // Set listeners taskCheckbox.setOnCheckedChangeListener(this); view.setOnClickListener(this); view.setOnLongClickListener(this); taskCheckbox.setOnClickListener(this); taskCheckbox.setOnLongClickListener(this); }
Example 10
Source File: InstantImageAdapter.java From PixImagePicker with Apache License 2.0 | 5 votes |
Holder(View itemView) { super(itemView); preview = itemView.findViewById(R.id.preview); selection = itemView.findViewById(R.id.selection); isVideo = itemView.findViewById(R.id.isVideo); itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); }
Example 11
Source File: DetailsActivity.java From ExpressHelper with GNU General Public License v3.0 | 5 votes |
private void addDetailsItem(String title, String info) { View v = View.inflate( new ContextThemeWrapper( getApplicationContext(), R.style.Base_Theme_AppCompat_Light ), R.layout.simple_list_item, null ); ((TextView) v.findViewById(android.R.id.text1)).setText(title); ((TextView) v.findViewById(android.R.id.text2)).setText(info); v.setTag(title + ": " + info); v.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { setClipboard((String) view.getTag()); Toast.makeText( getApplicationContext(), R.string.details_has_copied, Toast.LENGTH_SHORT ).show(); return true; } }); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); mContentLayout.addView(v, 0, lp); }
Example 12
Source File: ItemClickSupport.java From FirebaseMessagingApp with GNU General Public License v3.0 | 5 votes |
@Override public void onChildViewAttachedToWindow(View view) { if (mOnItemClickListener != null) { view.setOnClickListener(mOnClickListener); } if (mOnItemLongClickListener != null) { view.setOnLongClickListener(mOnLongClickListener); } }
Example 13
Source File: MediaStoreRecyclerAdapter.java From libcommon with Apache License 2.0 | 5 votes |
@NonNull @Override public ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) { final View view = mInflater.inflate(mLayoutId, parent, false); view.setOnClickListener(mOnClickListener); view.setOnLongClickListener(mOnLongClickListener); return new ViewHolder(view); }
Example 14
Source File: ChatFragment.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 5 votes |
@Override public EmoteViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater .from(parent.getContext()) .inflate(R.layout.view_emote_showcase, parent, false); itemView.setOnClickListener(emoteClickListener); itemView.setOnLongClickListener(emoteLongClickListener); return new EmoteViewHolder(itemView); }
Example 15
Source File: CalibrationDataTable.java From xDrip with GNU General Public License v3.0 | 4 votes |
void bindView(View view, final Context context, final Calibration calibration) { final CalibrationDataCursorAdapterViewHolder tag = (CalibrationDataCursorAdapterViewHolder) view.getTag(); tag.raw_data_id.setText(JoH.qs(calibration.bg, 4) + " "+ BgGraphBuilder.unitized_string_static(calibration.bg)); tag.raw_data_value.setText("raw: " + JoH.qs(calibration.estimate_raw_at_time_of_calibration, 4)); tag.raw_data_slope.setText("slope: " + JoH.qs(calibration.slope, 4) + " intercept: " + JoH.qs(calibration.intercept, 4)); tag.raw_data_timestamp.setText(JoH.dateTimeText(calibration.timestamp) + " (" + JoH.dateTimeText(calibration.raw_timestamp) + ")"); if (calibration.isNote()) { // green note view.setBackgroundColor(Color.parseColor("#004400")); } else if (!calibration.isValid()) { // red invalid/cancelled/overridden view.setBackgroundColor(Color.parseColor("#660000")); } else { // normal grey view.setBackgroundColor(Color.parseColor("#212121")); } view.setLongClickable(true); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: calibration.clear_byuuid(calibration.uuid, false); notifyDataSetChanged(); break; case DialogInterface.BUTTON_NEGATIVE: break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage("Disable this calibration?\nFlagged calibrations will no longer have an effect.").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return true; } }); }
Example 16
Source File: ActivityWithContextMenu.java From fogger with Apache License 2.0 | 4 votes |
@Override public void unregisterForContextMenu(View view) { super.unregisterForContextMenu(view); view.setOnLongClickListener(null); }
Example 17
Source File: BaseAdapterHelper.java From BigApp_Discuz_Android with Apache License 2.0 | 3 votes |
/** * Sets the on long click listener of the view. * * @param viewId The view id. * @param listener The on long click listener; * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setOnLongClickListener(int viewId, View.OnLongClickListener listener) { View view = retrieveView(viewId); view.setOnLongClickListener(listener); return this; }
Example 18
Source File: BaseAdapterHelper.java From UltimateRecyclerView with Apache License 2.0 | 3 votes |
/** * Sets the on long click listener of the view. * * @param viewId The view id. * @param listener The on long click listener; * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setOnLongClickListener(int viewId, View.OnLongClickListener listener) { View view = retrieveView(viewId); view.setOnLongClickListener(listener); return this; }
Example 19
Source File: CheatSheet.java From material-intro with MIT License | 2 votes |
/** * Removes the cheat sheet for the given view by removing the view's {@link * android.view.View.OnLongClickListener}. * * @param view The view whose cheat sheet should be removed. */ public static void remove(final View view) { view.setOnLongClickListener(null); }
Example 20
Source File: BaseViewHolder.java From basic-adapter with MIT License | 2 votes |
/** * Sets the on longClick listener of the view. * @param viewId * @param listener * @return */ public BaseViewHolder setOnLongClickListener(int viewId, OnLongClickListener listener) { View view = getView(viewId); view.setOnLongClickListener(listener); return this; }