I search for a good and handy user interface to put items from list 1
to a empty list 2 with drag&drop. I need this function for Android 2.2.
Have anybody heard about this feature?
EDIT
I found this website and i think it is also interesting.
http://techdroid.kbeanie.com/2010/04/simple-drag-n-drop-on-android.html
Look also at the comments.
It may also be helpful to reference my simple Drag and Drop list. You can find here
if u don't getting then use this
An example of this in github https://github.com/mtparet/Drag-And-Drop-Android
It could help you.All contribution are welcome
Take a look at this sample that Drag and drop inside a List View..
Refer to the drag and drop API launched in API Version 11
http://developer.android.com/guide/topics/ui/drag-drop.html
A drag and drop operation starts when the user makes some gesture that you recognize as a signal to start dragging data. In response, your application tells the system that the drag is starting. The system calls back to your application to get a representation of the data being dragged. As the user's finger moves this representation (a "drag shadow") over the current layout, the system sends drag events to the drag event listener objects and drag event callback methods associated with the View objects in the layout. Once the user releases the drag shadow, the system ends the drag operation.
Related
I want to implement touch listener that detects
Click/tap on chess piece in order to select ot
Swipe/move of chess piece immediately.
How to do it?
Unfortunately, I am not sure what you mean by a "chess piece", but let's assume that the board is a view in the background, and inside you have inner views which are chess pieces.
To achieve the select/unselect given piece effect you should add a simple View.OnClickListener interface to your view. Each of your pieces should have a view class and some data connected to it (like a position, a type of piece, id, etc.). After clicking the piece update the state of some global variable, for example, selectedPiece with an ID assigned to a given piece. You should also change the UI of a given piece, for example change the border to show the selected piece to a user. Then after clicking a new field for moving the piece you should update the UI by moving your piece view to an appropriate position. Also, the data of a piece or a game should be updated - depending on the place of storing the pieces' positions.
For this you should implement the drag&drop feature which is described here: https://www.tutorialspoint.com/android/android_drag_and_drop.html. You should determine the places where the user can move a piece and in case of dropping the piece in the wrong place, cancel the move and go with the piece to a start position.
Basic response to touch events using event.x and event.y works:
https://developer.android.com/develop/ui/views/graphics/opengl/touch
https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038
...more info:
Android Touch Listener
I want to create a list, for example, To-Do List.
In this User is allowed to select/unselect an item, reorder according to their priority. In the current scenario, I am able to give them all of the above functionality using ItemTouchHelper.SimpleCallback.
My Challenge starts here -
When User selects an item(or right swipe it) I need to show that row disabled with strike-through text.
In such a case, I am changing its position and after that, all features like Drag & Drop, Swipe Left or Right should not work on that particular row.
And, If the user manually unselects it by tapping an icon, all the mentioned gestures should work.
I read about Method getSwipeDirs but didn't understand how to utilize it in my scenario.
I have gone through a couple of articles but all of them remove an item on swipe. Hence, I couldn't find the reference for my case.
If anyone has an idea about it and guide me further then it would be a great help! I am open
Note: I have used com.daimajia.swipe.SwipeLayout library just for left swipe as I want to enable full swipe just for Right direction. I am able to disable the library swipe by utilizing some of its methods. However, I still can not disable Drag/Drop or Right Swipe which I am using with help of ItemTouchHelper.SimpleCallback.
We can simply add the tag to the viewHolder of recyclerView and fetch the info from the tag for any particular row in the getMovementFlags method of ItemTouchHelper.Callback and manipulate drag/ drop or swipe flag as needed!
I have a ListView that is filled with contacts. When a user starts to drag a shareable item, this list appears. To highlight the currently selected contact I animate the profile picture in the drag event.
When I move the drag shadow to the bottom the list scrolls down using a custom defined method. I call NotifyDataSetChanged afterwards. This works for scrolling and all contacts are shown fine, but after I scroll no drag events are received on the contacts anymore (so no animations are being shown, plus I don't know when the user actually drops the item).
I read somewhere that this is because they are not registered as drop targets. So, my question is, how do I register them?
Using Xamarin.Android BTW, but I don't think that changes anything, Java answers are welcome too :)
Ok, I figured it out.
A workaround exists, setting items newly scrolled into view to Visibility.Invisible and then back to Visible registers them as a drop target.
I created a custom ListView that scrolls automatically when a user is currently dragging something and also registers items that come into view.
See this gist.
Working flawlessly!
I have a list that uses a database to display some data. There are several operations that the user can perform on each list item and instead of implementing a context menu where the user uses a long press to bring up a list of possible operations I would like to add buttons to each item so the user can just tap the button and perform the operation. The list can be potentially large and attaching a listener to each button for each list item is overkill so I would like to do what Javascript programmers do with event bubbling, i.e. attach a single handler to a top level element like the entire list and let the click events bubble up to it. How would I go about doing this?
View.OnClickListener.onClick() does not bubble, so the solution you propose would not work.
OTOH, View.OnTouchListener.onTouch() does bubble so this could possibly be used, but it would require you to manually handle MotionEvent's down/up to detect a click.
Besides, if you create a lot of Buttons, than are you sure that adding onCLick handlers would be a lot of overhead, especially since you can register the same method for all of them.
What you are trying to do sounds like a premature optimization. Be sure there is real overhead affecting your users, before you try to deal with it.
I am designing an application which requires Drag&Drop functionality to transfer items from one list to another.
Is there any way to drop item into another list, as i have seen applications to drag and drop items in the same list(Reordering the list)?
This is more of a direction to investigate than an answer: Have you tried listening to the button/touch down event in one list to get the item the use wants to drag, and then listening to the button/touch up event in the other list so that you know what index to insert the item at?
In the button/touch down event handler, the View object being touched is passed in. In order to recover the original object that you used to create the View, you can attach it to that view via the setTag() function and recover it from the getTag() function within the event handler.
This wouldn't take care of any animation, but might achieve the desired functionality.