<LinearLayout
style="@style/linlay_main_time_template"
android:gravity="center_vertical"
android:weightSum="1" >
<!-- Layout Time zone name(Time zone City and Country) starts here. -->
<LinearLayout
android:id="@+id/ll_tzname"
style="@style/linlay_times_detail"
android:layout_weight="0.6"
android:gravity="center_vertical"
android:minWidth="100dp" >
<TextView
android:id="@+id/tv_tz_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOS ANGELES"
android:textColor="@color/tz_city_color"
android:textSize="13sp" />
<TextView
android:id="@+id/tv_tz_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UNITED STATES"
android:textColor="@color/tz_city_color"
android:textSize="13sp" />
</LinearLayout>
<!-- Layout Time zone name(Time zone City and Country) ends here. -->
<!-- Layout Time zone Time starts here. -->
<LinearLayout
android:id="@+id/ll_tz_time"
style="@style/linlay_times_detail"
android:layout_marginRight="3dp"
android:layout_weight="0.04"
android:gravity="left" >
<TextView
android:id="@+id/tv_tz_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="12:03"
android:textColor="@color/tz_time_color"
android:textSize="45sp" />
</LinearLayout>
<!-- Layout Time zone Time ends here. -->
<!-- Layout Time zone Am/Pm and Day Name starts here. -->
<RelativeLayout
android:id="@+id/ll_ampm_day"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginBottom="7dp"
android:layout_marginTop="7dp"
android:layout_weight="0.3"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_tz_ampm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="AM"
android:textColor="@color/tz_city_color"
android:textSize="13sp" />
<TextView
android:id="@+id/tv_tz_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="FRI"
android:textColor="@color/tz_city_color"
android:textSize="13sp" />
</RelativeLayout>
<!-- Layout Time zone Am/Pm and Day Name ends here. -->
<!-- Layout Edit Time zone Time starts here. -->
<LinearLayout
android:id="@+id/ll_tz_edit_time"
style="@style/linlay_times_detail"
android:layout_weight="0.2"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_edit_time"
style="@style/style_wrap_height_width"
android:background="@drawable/edit_time_icon"
android:visibility="gone" />
<!-- Drag Handle -->
<ImageView
android:id="@id/drag_handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/drag_icon"
android:visibility="visible" />
</LinearLayout>
<!-- Layout Edit Time zone Time ends here. -->
</LinearLayout>
<!-- <View -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="1dp" -->
<!-- android:background="@color/tz_list_line_separator_color" /> -->
I'm adding array list of linear layout using custom base adapter.
But when I drag item it works fine but when I drop item it throw following error:
12-23 17:29:00.206: E/AndroidRuntime(27318): FATAL EXCEPTION: main
12-23 17:29:00.206: E/AndroidRuntime(27318): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addViewInner(ViewGroup.java:2007)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1902)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1859)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1839)
12-23 17:29:00.206: E/AndroidRuntime(27318): at com.mobeta.android.dslv.DragSortListView$AdapterWrapper.getView(DragSortListView.java:727)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.AbsListView.obtainView(AbsListView.java:1459)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.makeAndAddView(ListView.java:1786)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.fillDown(ListView.java:705)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.fillSpecific(ListView.java:1337)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.layoutChildren(ListView.java:1650)
12-23 17:29:00.206: E/AndroidRuntime(27318): at com.mobeta.android.dslv.DragSortListView.layoutChildren(DragSortListView.java:2136)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.AbsListView.onLayout(AbsListView.java:1310)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1290)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1166)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.onLayout(LinearLayout.java:1083)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewRoot.performTraversals(ViewRoot.java:1181)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewRoot.handleMessage(ViewRoot.java:1913)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.os.Handler.dispatchMessage(Handler.java:130)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.os.Looper.loop(SourceFile:351)
12-23 17:29:00.206: E/AndroidRuntime(27318): at android.app.ActivityThread.main(ActivityThread.java:3820)
12-23 17:29:00.206: E/AndroidRuntime(27318): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 17:29:00.206: E/AndroidRuntime(27318): at java.lang.reflect.Method.invoke(Method.java:538)
12-23 17:29:00.206: E/AndroidRuntime(27318): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
12-23 17:29:00.206: E/AndroidRuntime(27318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
12-23 17:29:00.206: E/AndroidRuntime(27318): at dalvik.system.NativeStart.main(Native Method)
Hi,
I'm trying to customize dslv with right handle. I'm using BaseAdapter whose code is given below:
my listview adapter code: package com.tekege.warptime.widget;
import java.util.ArrayList;
import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.LinearLayout;
public class DragSwipListViewAdapter extends BaseAdapter implements RemoveListener, DropListener {
// View v = super.getView(position, convertView, parent); try{ linear_layout_timezone = (LinearLayout) mContent.get(position); } catch(Exception e){ e.printStackTrace(); } return linear_layout_timezone; }
}
I'm adding items with this xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:textview="http://schemas.android.com/apk/assets/com.tekege.warptime.widget" android:id="@+id/linlay_main" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="1" >
I'm adding array list of linear layout using custom base adapter. But when I drag item it works fine but when I drop item it throw following error:
12-23 17:29:00.206: E/AndroidRuntime(27318): FATAL EXCEPTION: main 12-23 17:29:00.206: E/AndroidRuntime(27318): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addViewInner(ViewGroup.java:2007) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1902) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1859) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewGroup.addView(ViewGroup.java:1839) 12-23 17:29:00.206: E/AndroidRuntime(27318): at com.mobeta.android.dslv.DragSortListView$AdapterWrapper.getView(DragSortListView.java:727) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.AbsListView.obtainView(AbsListView.java:1459) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.makeAndAddView(ListView.java:1786) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.fillDown(ListView.java:705) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.fillSpecific(ListView.java:1337) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.ListView.layoutChildren(ListView.java:1650) 12-23 17:29:00.206: E/AndroidRuntime(27318): at com.mobeta.android.dslv.DragSortListView.layoutChildren(DragSortListView.java:2136) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.AbsListView.onLayout(AbsListView.java:1310) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1290) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1166) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.LinearLayout.onLayout(LinearLayout.java:1083) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.widget.FrameLayout.onLayout(FrameLayout.java:369) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.View.layout(View.java:7224) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewRoot.performTraversals(ViewRoot.java:1181) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.view.ViewRoot.handleMessage(ViewRoot.java:1913) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.os.Handler.dispatchMessage(Handler.java:130) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.os.Looper.loop(SourceFile:351) 12-23 17:29:00.206: E/AndroidRuntime(27318): at android.app.ActivityThread.main(ActivityThread.java:3820) 12-23 17:29:00.206: E/AndroidRuntime(27318): at java.lang.reflect.Method.invokeNative(Native Method) 12-23 17:29:00.206: E/AndroidRuntime(27318): at java.lang.reflect.Method.invoke(Method.java:538) 12-23 17:29:00.206: E/AndroidRuntime(27318): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969) 12-23 17:29:00.206: E/AndroidRuntime(27318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727) 12-23 17:29:00.206: E/AndroidRuntime(27318): at dalvik.system.NativeStart.main(Native Method)
Thanks