long-press

Android long press with scroll

删除回忆录丶 提交于 2019-12-04 01:48:50
问题 I want to "connect" long press with scroll, so the user doesn't have to release the screen and start to scroll. I have gesture detector implemented... final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { public void onLongPress(MotionEvent e) { // action 1 } public boolean onScroll(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) { // action 2 } } public boolean onTouchEvent(MotionEvent event) { return

How to display a button on long press of a list item

若如初见. 提交于 2019-12-03 19:05:12
I need to display a delete button on long press of a list item.. I've got the code for long press.. but don't know how to code for displaying a button inside this long press... Finally got the answer... .xml file <ImageButton android:id="@+id/imgdelete" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/delete" android:visibility="invisible"/> .java file lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { arg1.findViewById(R.id.imgdelete)

Simulate Long press by Touch events

本秂侑毒 提交于 2019-12-03 15:06:09
问题 How can we simulate long press by touch event? or how can we calculate the time that screen is touched, all in ACTION_DOWN state? 回答1: I have implemented a Touch screen long click finally , thx all: textView.setOnTouchListener(new View.OnTouchListener() { private static final int MIN_CLICK_DURATION = 1000; private long startClickTime; @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_UP: longClickActive = false; break; case

Using long press gesture to reorder cells in tableview?

ⅰ亾dé卋堺 提交于 2019-12-03 11:50:55
I want to be able to reorder tableview cells using a longPress gesture (not with the standard reorder controls). After the longPress is recognized I want the tableView to essentially enter 'edit mode' and then reorder as if I was using the reorder controls supplied by Apple. Is there a way to do this without needing to rely on 3rd party solutions? Thanks in advance. EDIT: I ended up using the solution that was in the accepted answer and relied on a 3rd party solution. samuelsaumanchan So essentially you want the "Clear"-like row reordering right? (around 0:15) This SO post might help.

MultichoiceModeListener on RecyclerView android

感情迁移 提交于 2019-12-02 01:58:30
I have a recyclerview with respective adapter. I want to show multiple customview menu options in toolbar on the long press of recyclerview item. Any help is highly appreciated. Thanks in advance. I'm doing the same work. This post is helpful: RecyclerView with choice modes Basically you have to add this code in your OnLongClick method @Override public boolean onLongClick(View view) { if (!mMultiSelector.isSelectable()) { ((AppCompatActivity) getActivity()).startSupportActionMode(mActionModeCallback); // (2) mMultiSelector.setSelectable(true); mMultiSelector.setSelected(MyViewHolder.this, true

long press on selected text in textview in android [closed]

你。 提交于 2019-11-30 04:08:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In my android app, I have a text view and some text in it. I want that user can see the meaning of the words in a tool tip box when he long press on the word . My problem is that I don’t know how to implement long press in the words.Can some body help me? Sorry for my poor English. 回答1: use following code: tv

UITableView need long press to select a row

假如想象 提交于 2019-11-29 14:08:01
Anyone has ever come into the problem that UITableView need long press to trigger the didSelectRowAtIndexPath method? If you have used any gesture recognizer try to removing it and check if it causing the problem or not ? Other wise Not sure but The problem might be in the UITableView has delaysContentTouches turned ON . Turn this OFF so touches get through to the cells faster. In my situation I had a UITapGestureRecognizer on my view for hiding my keyboard. This solved the problem: tap.cancelsTouchesInView = false I had exactly the same trouble : I used the Tap Gesture recognizer to manage

How to differentiate between long key press and regular key press?

你离开我真会死。 提交于 2019-11-29 02:05:45
I'm trying to override the functionality of the back key press. When the user presses it once, I want it to come back to the previous screen. However, when the back key is long-pressed (for, let's say, two seconds or more), I want to exit the application. By now, I have overriden these two methods in my activity: @Override public boolean onKeyDown( int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK) { //manage short keypress return true; } return super.onKeyDown(keyCode, event); } @Override public boolean onKeyLongPress( int keyCode, KeyEvent event){ if (keyCode == KeyEvent

UITableView need long press to select a row

冷暖自知 提交于 2019-11-28 07:35:48
问题 Anyone has ever come into the problem that UITableView need long press to trigger the didSelectRowAtIndexPath method? 回答1: If you have used any gesture recognizer try to removing it and check if it causing the problem or not ? Other wise Not sure but The problem might be in the UITableView has delaysContentTouches turned ON . Turn this OFF so touches get through to the cells faster. 回答2: In my situation I had a UITapGestureRecognizer on my view for hiding my keyboard. This solved the problem:

How to differentiate between long key press and regular key press?

对着背影说爱祢 提交于 2019-11-27 16:20:12
问题 I'm trying to override the functionality of the back key press. When the user presses it once, I want it to come back to the previous screen. However, when the back key is long-pressed (for, let's say, two seconds or more), I want to exit the application. By now, I have overriden these two methods in my activity: @Override public boolean onKeyDown( int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK) { //manage short keypress return true; } return super.onKeyDown(keyCode, event