android-event

Let parent View assume MotionEvents if child returns false

瘦欲@ 提交于 2019-12-07 14:01:12
问题 I have a application that need event handling on a unusual way. For my question, let me first explain a simple case that the current event handling system of Android don't fits for me. Supposing that I have a FrameLayout (that I'll call ViewSwiper since now) that all Views added on it are MATCH_PARENT X MATCH_PARENT (that I'll call PageView), it's handles events by translating the actual View and replace it based on the direction of moving. This component I already have done and work properly

getDownTime() and getEventTime()

落花浮王杯 提交于 2019-12-07 07:05:02
问题 What is difference between:getEventTime() and getDownTime()? In documentation http://developer.android.com/reference/android/view/MotionEvent.html Both seems to do the same thing but they output different values. 回答1: getDownTime returns the time this series of events started. For example, if you got: ACTION_DOWN , ACTION_MOVE , and then ACTION_MOVE . If you call getDownTime on this latest event, you will get the time of the ACTION_DOWN , which is the event that started the series. If you

Let parent View assume MotionEvents if child returns false

大憨熊 提交于 2019-12-05 21:40:32
I have a application that need event handling on a unusual way. For my question, let me first explain a simple case that the current event handling system of Android don't fits for me. Supposing that I have a FrameLayout (that I'll call ViewSwiper since now) that all Views added on it are MATCH_PARENT X MATCH_PARENT (that I'll call PageView), it's handles events by translating the actual View and replace it based on the direction of moving. This component I already have done and work properly ( Using Animation to swipe views ). But the problem is on that PageView I add on top of it, in case of

getDownTime() and getEventTime()

倾然丶 夕夏残阳落幕 提交于 2019-12-05 12:28:16
What is difference between:getEventTime() and getDownTime()? In documentation http://developer.android.com/reference/android/view/MotionEvent.html Both seems to do the same thing but they output different values. getDownTime returns the time this series of events started. For example, if you got: ACTION_DOWN , ACTION_MOVE , and then ACTION_MOVE . If you call getDownTime on this latest event, you will get the time of the ACTION_DOWN , which is the event that started the series. If you call getEventTime you will get when the latest ACTION_MOVE happened. 来源: https://stackoverflow.com/questions

View.onTouchEvent only registers ACTION_DOWN event

落爺英雄遲暮 提交于 2019-12-05 12:05:38
问题 I'm implementing a custom TextView and I want to do some action when the view is touched. I figured the onTouchEvent method would give me the full range of touches on the view without having to use setOnTouchListener (I'm trying to do all my work inside the view instead of in the activity so it's portable), but the only touch event registered is ACTION_DOWN . If I set an OnTouchListener in the activity using this, I get the full range of touch events, but onTouchEvent doesn't. Anyone know why

How is it possible to know which View has clicked in a layout OnClickListener?

北城余情 提交于 2019-12-05 07:20:45
问题 I have a layout which contains some views. I want to set some actions when a user clicks anywhere in the layout, so I have set an OnClickListener for the layout which works clear. But how can I know which view was clicked? I want to assign different actions depends on the view which was clicked; or maybe no view was clicked and it was only the layout itself. So the problem is if I set OnClickListener for one of the views, both OnCLickListeners related to the layout and the view will get

How to Prevent Accidental App Exit w/in Android Fragments/Activities?

天大地大妈咪最大 提交于 2019-12-04 16:03:37
问题 How Do I Prevent Accidental App Exit w/in Android? IE: When the he/she presses the back button and reaches the last activity in the BackStack, show a toast to ask if the user wants to exit using the onBackPressed() method. Also, It needs to function with backStacks for fragments. 回答1: This functionality can easily be implemented by overriding main activity's onBackPressed() method. In this example when user presses back button then the app will display a toast for 4 seconds on which time a

How to prevent onTouch for parent Linear Layout from executing multiple times child?

耗尽温柔 提交于 2019-12-04 05:55:30
问题 On touch event for a lienar layout multiple screens pops up. It seems that the ontouch event gets fired twice for each child element of the linear layout. How can I prevent this from firing twice. On click event for the same linear layout causes, the linear layout onclick event to be fired on second click and not on the first click. I am not understanding where I am going wrong. Please help. -- XML <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android

Dispatch touch event from a view to his WebView sibling

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 01:24:38
问题 Resume of the problem : dispatch touch event on a layout to his WebView sibling achieving the same scroll than the default WebView scroll (with fling) I have a frameLayout over an WebView following this xml : <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.app.ObservableWebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/observableWebView"> <

How is it possible to know which View has clicked in a layout OnClickListener?

霸气de小男生 提交于 2019-12-03 21:01:35
I have a layout which contains some views. I want to set some actions when a user clicks anywhere in the layout, so I have set an OnClickListener for the layout which works clear. But how can I know which view was clicked? I want to assign different actions depends on the view which was clicked; or maybe no view was clicked and it was only the layout itself. So the problem is if I set OnClickListener for one of the views, both OnCLickListeners related to the layout and the view will get activated, but I want only the view action.Thanks in advance. Other answers are quite abstract and some are