Android - drag and drop - list rearrange - android

How can I create a list where I can rearrange list items with dragging
list rows to another row and so on (to change to order)?
Just like on the HTC Hero in the clocks app where you can rearrange
the order of clocks?

Even though this question is already answered. I struggled using the music app as an example, so I created a simple Drag and Drop List project to help others that can be found here

Pay special attention to this one
com.android.music.TouchInterceptor

You can also try my recent implementation here:
https://github.com/bauerca/drag-sort-listview
It gives smooth scrolling while dragging and supports list items with arbitrary heights. Lots of jumpy behavior has also been removed as compared to the TouchInterceptor.

It's in platform/packages/apps/Music/src/com/android/music/TouchInterceptor.java. Here's a direct link:
https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/TouchInterceptor.java

Hint: download the android sources and have a look how the Music app (packages\apps\Music) implements this functionality.

Related

Nativescript Vertical Screen Slide / ViewPager

What is the easiest way to implement a screen slide in Nativescript like shown in Android Viewpager , but in a vertical direction ? Another example of this functionality would be the rss reader feedly where you can change rss feeds by swiping up/down.
The page should allow vertical scrolling to the top/bottom and then transition after a certain treshold.
I already encountered nativescript-slides, which can only do horizontally sliding.
So is there a "nativescript" way or do i have to implement it as native android/ios feature (for example by this) ? In either case a sample on how to integrate it in nativescript would be great.
Update
Recorded an example:
taken from this Repo with Android native code. The outstanding PR made changes to offer vertical scrolling in the list. But the repo seems to be outdated and a bit buggy.
I can provide more info later but there's a new plugin implementing the native controls for android and iOS for slides/carousel her https://github.com/alexrainman/nativescript-carousel-view and vertical swiping is on his radar, I think he might even be close to completing that.
To give an answer for anybody interested in above nested scrolling animation:
For Android I had to implement the native ReyclerView in Nativescript in favor of the NS buildin ListView. It is an optimized view structure which among other things allows nested (vertical) scrolling and can be used as replacement for an ordinary list.
Together with https://github.com/alexrainman/nativescript-carousel-view works like a charm!
Anyone that ends up here still looking for ways to achieve this.
I spent a lot of time trying to figure out a way to achieve this and tried to find ready plugins for this. Also tried to use the plugin from Alexrainman but eventually gave up since the plugin was not up to date with the current nativescript-version.
My solution:
I used radListView as a basis for this implementation and leveraged the methods and events on the radListView.
By using scrolled-event I gathered data for the use of the scrolling feature: scroll Speed and scroll direction. (These might be also taken from the event data, but since I did not find the event details from the Nativescript-documentation I gave up trying to guess where to find this data on the event-model).
Then I also saved the fixed height of one item on my list (The height I fixed to screenHeight-200).
With all this info, I managed to hook the event "ScrollDragEnded" and add logic that makes my list behave like a vertical slider. Moving on the list by method "scrollToIndex" and figuring out which index to scroll and when by leveraging all the data mentioned above.
This is the way I managed to make a pretty good vertical slide.
Good luck!

MvxListView in Android with MvvmCross

I'm using MvvmCross v3 and I have a little problem with list in Android.
I actually have a Mvx.MvxListView who works well, but I'm working on tablet, and ListView is a little bit inapropriate. So I want to have a control like WrapPannel in XAML to have more than one item in a row.
How can I have this kind of control?
Thanks
There are two challenges here:
1. Find or make the control you want
The first is really up to you and your UX/design team to do - although people might be able to suggest apps and projects which might help. When choosing a control always be careful to understand it's memory use - especially:
whether it virtualises the UI reusing cells (like a list does)
or whether it creates a cell for every item even if the item is not visible (like a SL WrapPanel does?)
2. Add data-binding to it
This second step is generally quite simple to do - take a look at one of the Mvx layout controls and see how it is converted for databinding - e.g. https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxLinearLayout.cs
You can generally just cut-and-paste this code over to your new type.
For more on subclassing existing types, also see N=18 in the video series - http://slodge.blogspot.co.uk/2013/05/n18-android-custom-controls-n1-days-of.html - this shows subclassing of a TextView
For a wrappanel, I did previously adapt and use one of #CheeseBaron's ports - FlowLayout - see http://slodge.blogspot.co.uk/2013/01/an-mono-for-android-wrappanelflowlayout.html. However, this has not been updated for v3 - if you do update it, it'd be great if you shared the results back.

how to drag and drop in android?

my android version is 2.2
I want to make ui like easyband (youtube video)
so, how to drag and drop imageView or button between other layout?
and I want know insert imageView or button array of items to use drag and drop
plz help me
Your answer would be Android drag and drop framework.
However, I guess you are just at the beginning to solve your problem, try to ask more specific questions (like I have tried this method and it's giving me this error) instead of looking for a whole answer
Try creating a GridView that allows you to drop views from one area to another. Here is Bill Lahti's code and examples of the similar Drag and Drop effect on lower API's.
http://blahti.wordpress.com/2011/02/10/moving-views-part-3/
http://blahti.wordpress.com/2012/03/03/improved-drag-drop-for-gridview/
Also, explore his content and hopefully you will find what you need.

Is there something like a ListView that allows dynamic relocation of ListView elements drag-and-drop style?

I am having a hard time describing this in a way Google will understand. Is there a list object that has the capability to drag a List element and move it up or down to the desired location?
ya. check this link out : https://github.com/commonsguy/cwac-touchlist.
Actually this has been implemented in the Android Music application. Just take a look at the source code as well.
Please make sure you research your question before posting. This has been discussed a lot of times in stack overflow.. possible duplicates here :
Android List View Drag and Drop sort
How can I allow a user to re-sort items in a list?

reordering of listview items by drag and drop using android

How to drag and drop items in Listview for reordering in android?
Here is our drag & drop list. It is a direct replacement for ListView and it's very easy to use. There are examples of how to use it on the github page.
https://github.com/terlici/DragNDropList
A good example on the topic can be found here: https://github.com/mtparet/Drag-And-Drop-Android
This has been discussed elsewhere. Try:
Reordering Lists like playlists in the media player
or
Android - drag and drop - list rearrange
Unfortunately, there seems to be no easy way to do it. You'll have to handle touch events at a fairly low level.
Check this.. exactly what you needed.
Drag and Drop

Categories

Resources