woxblom / draglistview Goto Github PK
View Code? Open in Web Editor NEWDrag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.
License: Apache License 2.0
Drag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.
License: Apache License 2.0
Xml File Set Inner
<com.woxthebox.draglistview.DragListView
android:id="@+id/lv_academy"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Error Content
Rendering Problems
java.lang.IllegalAccessException: Class com.android.layoutlib.bridge.util.ReflectionUtils can not access a member of class com.woxthebox.draglistview.DragItemRecyclerView with modifiers "public" at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) at java.lang.reflect.Method.invoke(Method.java:490) at com.android.layoutlib.bridge.util.ReflectionUtils.invoke(ReflectionUtils.java:45) at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:126) at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:120) at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setLayoutManager(RecyclerViewUtil.java:78) at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setAdapter(RecyclerViewUtil.java:59) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.woxthebox.draglistview.DragListView.createRecyclerView ... (DragListView.java:131) at com.woxthebox.draglistview.DragListView.onFinishInflate(DragListView.java:94)
Maybe private or Protectd -> public change?
you have any idea how to use this drag and drop in Horizontal scroll view
hello Woxblom
I want to implement the code of remove item on an event of swipe up and down.
If u have any idea Please, help me.
Thanks.
I want Scale items in the board.
I edit code BoardView.java in method onFinishInflate().
add
float SCALE = 0.7f;
mRootLayout.setScaleX(SCALE);
mRootLayout.setScaleY(SCALE);
mRootLayout.setPivotX(SCALE);
mRootLayout.setPivotY(SCALE);
to bottom method onFinishInflate().
but when drag drog then dragItem not correct postion.
and the size of mRootLayout not change.
Can you help me for it ?
Thanks!
Is it possible to drag an item not just by its image? Like anywhere from the item row? Thanks!
See the Method i am using to add multiple List in Board View.
private void addColumnList(List mItemArrayParent) {
ArrayList<Pair<Long, ProjectsList>> mItemArray = new ArrayList<>();
for (int i = 0; i < mItemArrayParent.size(); i++) {
for (int loop=0;loop<mItemArrayParent.get(i).getProjectList().size();loop++) {
ProjectsList projectsList = mItemArrayParent.get(i).getProjectList().get(loop);
mItemArray.add(new Pair<>(Long.parseLong(projectsList.getProjectID()), projectsList));
}
int addItems = mItemArray.size();
Log.e("Size","/"+addItems);
AdapterDepartment listAdapter = new AdapterDepartment(mItemArray, R.layout.column_item, R.id.item_layout, true);
View header = View.inflate(getActivity(), R.layout.column_header, null);
((TextView) header.findViewById(R.id.header)).setText(mItemArrayParent.get(i).getDeptName());
((TextView) header.findViewById(R.id.header_count)).setText(Integer.toString(addItems));
mBoardView.addColumnList(listAdapter, header, false);
mItemArray.clear();
}
}
Hello,
I want to achieve same thing as with listView.setCanNotDragAboveTopItem() but for the last item on the list. Is it possible? Maybe with DragListListener.onItemDragging()?
Thank you for the help!
Hi, it's me again from issue #40
I'm not sure if this problem is related to your library or not, so please kindly help if you have time.
The problem occurs here is when an EditText
is focused with myEditText.requestFocus();
or being pressed, the keyboard appears and covers that EditText (The EditTexts at the top of the screen which are still visible when the keyboard popups work just fine). I solved this problem once but the structure was different (Your DragListView
was a nested child inside a RecyclerView
). I solved it by setting the android:layout_gravity="top"
for the RecyclerView
parent. But now I don't need the nested anymore so your DragListView
is the parent now and I use ViewType to create the different ViewHolder. The android:layout_gravity="top"
won't work anymore.
I started thinking that maybe setting DragItemRecyclerView mRecyclerView
gravity to TOP may solve the problem.
I tried adding a new method into your DragListView
class:
public void setLayoutGravityToTop(){
ViewGroup.LayoutParams layoutParams = mRecyclerView.getLayoutParams();
LinearLayout.LayoutParams castLayoutParams = (LinearLayout.LayoutParams) layoutParams;
castLayoutParams.gravity = Gravity.TOP;
mRecyclerView.setLayoutParams(castLayoutParams);
Log.d("check","Done setting!");
}
But it doesn't seems to work. The Log was never shown.
If you're interested, you can visist my detailed question on Stackoverflow
Thank you.
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:-1).state:3
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4653)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4611)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:584)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:2977)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2901)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3277)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1877)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1653)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.HorizontalScrollView.onLayout(HorizontalScrollView.java:1474)
at com.woxthebox.draglistview.BoardView.onLayout(BoardView.java:115)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1183)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15133)
at android.view.ViewGroup.layout(ViewGroup.java:4862)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(L
How can I start this list view from a specific position?
If you add features drag column is too great!
Cheese.
Every time I try to make a list, even when the adapter is of this type:
ArrayList<Pair<Long, String>>
but actually I want to use ArrayList<Pair<Integer, DeliveryResponseViewModel>>
When DeliveryResponseViewModel is a Object I made.
The List is created with multiple spaces.
If I have 3 elements, it will create 9 spaces, with this logic: Right View, empty, empty, Second Right View, empty, empty, Third Right View, empty, empty
I think I being missing some kind of library maybe about the ProGuard rules, or maybe I missing something bigger.
Hi! are you thinking to make the headers draggable? I'm talking about the BoardView! It will be awesome to give the ability to drag also the whole column! i can look into it, just would like to know if you are already working on it!
Hello!
Your library is very good!Altouth I have a questiom. Is possible start the drag by long pressing the list item anywhere, and not only the image?
Thank you!
In DragItemAdapter
, you've got:
mGrabView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (mDragEnabled && event.getAction() == MotionEvent.ACTION_DOWN) {
mDragStartedListener.onDragStarted(itemView, mItemId);
return true;
}
if (!mDragEnabled && itemView == mGrabView) {
return onTouch(view, event);
}
return false;
}
});
Shouldn't onTouch(view, event)
be onItemTouch(view, event)
? Looks like you're going to get a stack overflow otherwise
Hi,
I need total count and all items as an array. How can i do that?
I want to send request to a web service.
Is there a way to get the reference of an item view in the list at a given position? How can one place different images on different rows, or do all the images have to be the same like in the demo.
@OverRide
public void onItemDragEnded(int fromPosition, int toPosition) {
if (Long.valueOf(toPosition).equals((Long)(mItemArray.get(toPosition).first))) {
Toast.makeText(mDragListView.getContext(), "Correct position", Toast.LENGTH_SHORT).show();
//change the color of item
} else {
Toast.makeText(mDragListView.getContext(), "Incorrect position", Toast.LENGTH_SHORT).show();
//change the color of the item
}
}
If the row is in its correct position, the row should change its color. Also, this row should not be draggable anymore. How can I acheive this?
Hello how can i add a header section to the draglistview?
Hi use a grat libray (yes, your is also great): https://github.com/Ramotion/folding-cell-android.
When I use your DragListView, 3d effect of cell does not work. In fact view has the same size during animation, intead of become more larger. Maybe is an issue of your recycleview, or maybe of LinearLayout? I don' t know.
Hello! First of all thank you for the very useful library. As the title i want the BoardView only allows user to drop item from above of column. I managed to add a flag called "mCanNotDropBelowTopItem" and use it inside shouldChangeItemPosition method like this:
if(mCanNotDropBelowTopItem && newPos != mAdapter.getItemCount() - 1){
return false;
}
but it doesn't help. Any suggestion?
edit: "mAdapter.getItemCount() - 1" instead of 0 for "Top Item" is because i used "linearLayoutManager.setReverseLayout(true);" for RecyclerView.
When I remove an item from list using the following method:
public Object removeItem(int pos) {
if (mItemList != null && mItemList.size() > pos) {
Object item = mItemList.remove(pos);
notifyItemRemoved(pos);
return item;
}
return null;
}
The item is only HIDDEN and the row continue taking up space (the list height is not resized).
Here is my code:
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
String text = mItemList.get(position).second;
holder.itemView.setTag(text);
holder.mBtnDelete.setTag(position);
holder.mBtnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
removeItem(Integer.parseInt(String.valueOf(view.getTag())));
mDragListView.requestLayout();
}
});
}
Can you help me?
Thanks in advance (and sorry for my probably bad english),
Asia.
Hi Mr. Woxblom.
I'm trying to use your library, but I got problem when I setup targetSDK < 23. In dragging state, ListView's scroll height is not worked as expected.
Can you help me fix this problem.
Hi,
Thank you very much for this awesome bunch of code. It really helped me out.
Now I need to programmatically drag a specific row to a new row location.
Instead of dragging by finger I need to do that programmatically.
I checked on This link and This, But I couldn't get, that much of a clue.
For my requirement do I need to create my own DragEvent? (But how can I specify from :to movement of the row) or is it possible to use the existing code?
Regards,
Madusha
I tried ListView version. I wrap in FrameLayout like your example. Drag and drop works very bad. other item refresh layout with an hight frequency (maybe 50 fps).
Hi,
Thank you very much for this awesome bunch of code. It really helped me out.
Now I need to programmatically drag a specific row to a new row location.
Instead of dragging by finger I need to do that programmatically.
I checked on This link and This, But I couldn't get, that much of a clue.
For my requirement do I need to create my own DragEvent? (But how can I specify from :to movement of the row) or is it possible to use the existing code?
Regards,
Madusha
Hi, me again, enjoying this resource very much. However, I'm having trouble showing a DragListView
as a smaller portion of my fragment. In the screenshot, you can see that the DragListView
is occupying all the vertical space it can instead of wrapping to the height of only its 3 items. It would be great if the view could dynamically size to be just tall enough for its items. If an item were added/removed, it could then resize, like a regular ListView. Or am I missing something?
My code is below the screenshot.
My layout. Notice I have a commented-out ListView which I used to confirm that a normal ListView wraps its height with the exact same attributes.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relLay_dialog_semester_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/select_semester_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_semester_prompt"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<com.woxthebox.draglistview.DragListView
android:id="@+id/drag_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/select_semester_prompt"
android:layout_above="@+id/tv_add_semester"/>
<!--
<ListView
android:id="@+id/drag_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/select_semester_prompt" />
-->
<TextView
android:id="@+id/tv_add_semester"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="20dp"
android:layout_marginTop="10dp"
android:clickable="true"
android:layout_centerHorizontal="true"
android:text="+ Add a Semester"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/primary_dark"
android:textSize="20sp" />
</RelativeLayout>
Code where I set up the DragListView:
private void setupListView(){
mDragListView = (DragListView) rootView.findViewById(R.id.drag_list_view);
mDragListView.setDragListListener(new DragListView.DragListListener() {
@Override
public void onItemDragStarted(int position) {
Toast.makeText(getActivity(), "Start - position: " + position, Toast.LENGTH_SHORT).show();
}
@Override
public void onItemDragEnded(int fromPosition, int toPosition) {
if (fromPosition != toPosition) {
Toast.makeText(getActivity(), "End - position: " + toPosition, Toast.LENGTH_SHORT).show();
}
}
});
mDragListView.setLayoutManager(new LinearLayoutManager(getActivity()));
listAdapter = new Adapter_SemesterDragItemAdapter(semesterList, R.layout.semester_list_item, R.id.color_tab, false);
mDragListView.setAdapter(listAdapter, true); // has fixedItemSize
mDragListView.setCanDragHorizontally(false);
// ListView tmpListView = (ListView) rootView.findViewById(R.id.drag_list_view);
// Resources res = getResources();
// ArrayAdapter<Semester> tmpAdapter = new ArrayAdapter<Semester>(getActivity(), R.layout.my_spinner_item, semesterList);
// tmpListView.setAdapter(tmpAdapter);
}
This works great on API 21 and newer, but crashes on API 19 or earlier... Here is the stacktrace log...
Help! Thanks!
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.waynejohnson.converter, PID: 2839
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.waynejohnson.converter/com.waynejohnson.converter.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:621)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.view.View.inflate(View.java:17465)
at com.woxthebox.draglistview.DragItem.(DragItem.java:52)
at com.waynejohnson.converter.fragments.FavoritesFragment$MyDragItem.(FavoritesFragment.java:322)
at com.waynejohnson.converter.fragments.FavoritesFragment.onCreateView(FavoritesFragment.java:109)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1677)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:604)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at com.waynejohnson.converter.MainActivity.onStart(MainActivity.java:495)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.view.View.inflate(View.java:17465)
at com.woxthebox.draglistview.DragItem.(DragItem.java:52)
at com.waynejohnson.converter.fragments.FavoritesFragment$MyDragItem.(FavoritesFragment.java:322)
at com.waynejohnson.converter.fragments.FavoritesFragment.onCreateView(FavoritesFragment.java:109)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1677)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:604)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at com.waynejohnson.converter.MainActivity.onStart(MainActivity.java:495)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0200be a=-1 r=0x7f0200be}
at android.content.res.Resources.loadDrawable(Resources.java:2073)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.(View.java:3554)
at android.view.ViewGroup.(ViewGroup.java:470)
at android.widget.LinearLayout.(LinearLayout.java:176)
at android.widget.LinearLayout.(LinearLayout.java:172)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.view.View.inflate(View.java:17465)
at com.woxthebox.draglistview.DragItem.(DragItem.java:52)
at com.waynejohnson.converter.fragments.FavoritesFragment$MyDragItem.(FavoritesFragment.java:322)
at com.waynejohnson.converter.fragments.FavoritesFragment.onCreateView(FavoritesFragment.java:109)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1677)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:604)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at com.waynejohnson.converter.MainActivity.onStart(MainActivity.java:495)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Trying to run your DEMO gives me this error:
01-24 15:38:34.486 25175-25175/se.lamnea.exhibition.admin E/AndroidRuntime: FATAL EXCEPTION: main
Process: se.lamnea.exhibition.admin, PID: 25175
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.woxthebox.draglistview.DragItemAdapter.getPositionForItemId(long)' on a null object reference
at com.woxthebox.draglistview.DragItemRecyclerView.onDragStarted(DragItemRecyclerView.java:258)
at com.woxthebox.draglistview.DragListView$2.onDragStarted(DragListView.java:146)
at com.woxthebox.draglistview.DragItemAdapter$ViewHolder$1.onLongClick(DragItemAdapter.java:121)
at android.view.View.performLongClick(View.java:5236)
at android.view.View$CheckForLongPress.run(View.java:20900)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
I am using your ListFragment
class and haven't changed anything about what items are being populated or not.
It seems like the item adapter (here I also use the DEMO ItemAdapter
) is null for some reason? But this line is in ListFragment
, setting the adapter:
mDragListView.setAdapter(listAdapter, true);
What am I doing wrong? Thank you for the help!
I just tried wrapping my DragListView in a Scrollview, but when I try to drag to the bottom, it doesn't seem to scroll.
I notice the sample code uses a SwipeRefreshLayout to achieve this affect, but I was wondering if it was possible to do with a ScrollView as well.
Hello! very good library man. Thank you!
My question is how can i set fastScroll by a thumb?
Hello,
Thanks for the handy library. One thing I am unsure of is what kind of input is needed for the grabHandleId. Is it an image? the id of the view to be grabbed?
In your examples, you have it as R.id.image, but when I put in 'R.id.randomBitmap' of my own, it doesn't work. I assume I'm putting the wrong sort of thing in.
yours:
ItemAdapter listAdapter = new ItemAdapter(mItemArray, R.layout.list_item, R.id.image, false);
Mine:
MyDragItemAdapter mdia = new MyDragItemAdapter(array, R.layout.my_item, R.id.bracket, false);
Cheers for the help.
Hi Wox,
I'm probably missing something here.
Hi,
I have an EditText
inside the drag item. I want to edit that EditText
when I click on it and drag the item with a long-click but it's currently seems impossible to me. It starts to drag when I click it (without having to "long-click").
I tried to force onItemLongClicked
(of the viewholder) to return false
or true
but neither works. I also tried setting the grabhandle to the container layout of the whole item (the current grabhandle is the EditText) but then I can't always drag (maybe because the child views almost fill the container), but even if I can drag the item, it's "click to drag" not "long-click to drag".
Am I missing something here? How can I accomplish it?
Thank you.
Hi! How can I scroll programmatically list from this library?
Hi,
How can I get the child view from DragListView. I tryed using mDragListView.getChildAt(0).findViewById(R.id.ed_choise_item) but returns null. Could you please help me with this
I wish there is a call back method that can decide if the item should be able to drag or not.
Thank you.
i want to change the position of two items without change the position of the other items example:
1
2
3
4
Change between 1 and 4
4
2
3
1
Hello. Why your lybrary supports only Linearlayoutmanager? I have exception, if I use Staggeredgridlayoutmanager.
Hi Developers this beautiful tool. At first I want say thank you for develop the this good library.
My problem:
After update the support library recycler view recyclerview-v7:23.2.0, we receive new future it's wrap_content of height recycler view. So I want test it opportunity, and changed the recycler view for this library. And DragListView widget may set wrap_content only after dragged item. So how I can drag item programmatically ? Or please fix that problem. Thanks.
Hi,
I have used your code of DragListView. it's working perfect but now i want to drag whole column of board view than please can you help me
Great library! I'm planning to use it in one of my project but i cannot find a direct way to enable and disable the drag&drop without mess up with your code.
am I missing something?
Is there a reason that the minSdkVersion is 16 for this package? I was really hoping to use it in my project, but my minSdkVersion is 11.
Hi,
I would like to update data on the item being dragged.
For example (attached picture), I'm dragging Item 2, so I would like to change Item 2 data on the fly, on every canDragItemAtPosition event, that is, Item 1 should show dynamic data along the way being moved.
Is there a way to get access to that view being dragged?
Any idea would be appreciated.
I was looking to create something to this effect using the vertical listview:
TextView(Section Header)
1 CardView
2 CardView
3 CardView
ImageView(Divider)
TextView(Section Header)
4 CardView
5 CardView
6 CardView
7CardView
ImageView(Divider)
The cards should be able to be dragged above and below all CardViews, TextViews, and ImageViews.
The only way I can see of doing it is by manually changing the viewholder in onbind by setting the visibility of elements etc which is really nasty.
Is there any other way of achieving this?
Setter methods used by PropertyValuesHolder should be kept during obfuscation.
Hello,
I am using this library but the drag process start just after touch an item, I would like that drag process start after long press, is it possible?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.