I have a layout with a TextView in a ScrollView because scrolling in the TextView doesn't work well and I have a custom ActionMode in addition to the default txt ActionMode and scrolling in the textview directly for some reason destroys my ActionMode.
However, my Problem:
In my app you can make selection in the text and edit those selections later, I implemented these selections myself since the 'normal' selection mode doesn't work (no handles on selections that were set programatically...!?) When I edit a selection it works as long as the text is not scrolled (i.e. the top line is on top of the scrollview). When the text is scrolled, the selection works as long as I stay in the same line. Once I go up or down, the TextView's onTouch gets a 'cancel' event and the OnTouchListener of the ScrollView is called...
1) Why does the TextView's MotionEvent get cancelled?
2) Is there a way I can prevent it? Maybe tell the ScrollView to ignore everything for the time I'm editing the selection?
3) Is there a way I can map the coordinates that I get in the ScrollView's onTouch to coordinates in the TextView?? (So I could at least dispatch the event to the txt view and 'pretend' as the 'cancel' never happened....
Any ideas???
Thanks
Ok I found a solution.
I implemented my own ScrollView where I overwrite onInterceptTouchEvent and return false while the textView is being edited...
Related
I have a Listview in a Fragment, and when I click an item a new Fragment is shown.
The problem is that for few milliseconds i can see the item selected by the touch. Is there a way to make these Listview programmatically selectable only? For example when I return to the Fragment and something connected is running (i already know how to select an item in Java, i just need to know how to disable touch clicks).
The item is colored with a selector and the Listviews are set to choice mode single.
One way to do it would be to implement the ontouchListener() of the fragment, and rewrite the onTouch() method with a simple:
return false
to consume the event.
You can achieve this quite easily. The two ways that are on top of my head are :
Disable touch on the list.
Put your ListView in a RelativeLayout (rootLayout) in the RelativeLayout(rootLayout) first item should be your ListView and the second can be another RelativeLayout(coverLyt) with height and width set as match_parent and clickable set to true. This will make the coverLyt take the touch events instead of your ListView. When you want the listView touch events to work set coverLyt's visibility to gone and visible when vice versa.
I have a android app and with several Textviews inside linear layyout which is inside scrollview. On a button click I can bring focus and animate any textView (like move left to right). But What I want is, On Scrolling, if a TextView has Focus, animation for this textView should start. Just like this website.
I have an idea, which is: If scroll changes, check textview.hasFocus(), if true then startAnimation. But I don't know which method to use for checking 'if page scrolled'? I don't even know if this is right approach? Please help.
I have a ViewFlipper that hold a TextEdit that fills the parent.
When i swipe on the TextEdit it pops the keyboard to enter text, but i want to flip the view on swipe.
How can i implement this functionality?
Should i implement Gesture detection for the EditText or is there a way to ignore or pass the touch event to the parent?
Thank you.
If You set the Layout of Your EditText View to Match_Parent, then there is no possibility, to touch besides the view, so it automatically opens the keyboard. What You can do is to minimize the EditText and center it inside the ViewFlipper, so there is a little bit place besides the view. Another solution is to disable EditText on your ViewFlippers Gesture Event and enable it if the event has done. But I didn´t try this, it´s just an idea.
I have a problem where I have several TextView objects in my Activity. More than can fit on the screen view so I have placed them inside a ScrollView.
Now each TextView item is placed into a RelativeLayout before placing onto the ScrollView.
Each RelativeLayout object then has onClickListener and onFocusChangedListeners assigned.
Each Listener implements a method that pops up a dialog to enable the user to edit the value stored by the TextView.
The problem that is occuring is that when the screen is scrolled the onFocusChangedListener event is fired causing the dialog to appear for several items at a time.
Is it possible to detect if the Scrollview is scrolling and prevent the onFocusedChanged event firing?
I can post code if required but its quite large as the items added to the page are done so dynamically. This also means there is no xml for the layout.
I looked at using the ScrollView onTouchListener to add a flag ignoreFocusChange but it appears this would not work as the event was hit sveral times for one swipe/fling on the screen.
Please help
Regards,
Iain
After spending some time on this I found that the best solution for me was to remove the onFocusChangedListener and replace it with onTouchListener
I have a ScrollView in which I have a quite long form, mainly using EditText elements. The problem is, that when the user scrolls around in this form, ScrollView changes the focus constantly. It seemed to me, that it assigns focus to the first element on screen when the user stops touching the screen, and the fling motion triggers.
How can I disable this?
Just a thought that you can make EditText as non-focusable elements. And when user will click on any item in ListView you can make that particular element focusable again.