두 개의 목록보기가 있습니다. 그리고 하나의 목록보기에서 항목을 끌어서 다른 목록보기의 특정 위치에 놓기를 원합니다. 어떻게 할 수 있습니까? 이것은 내 레이아웃입니다.ListView 끌어서 놓기
<LinearLayout
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:id="@+id/vert1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_shadowed_frame"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="15dip" >
<TextView
android:id="@+id/tv1"
style="@style/TextViewMedStyleShadowWhite"
android:layout_width="wrap_content"
android:layout_height="30dip"
android:text="LIST 1"
android:textColor="@color/theme_blue" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="5dip"
android:background="@color/theme_blue" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:divider="@null"
android:paddingLeft="10dip"
android:paddingRight="10dip" />
<ProgressBar
android:id="@+id/progres1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/vert2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_shadowed_frame"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="15dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="15dip"
android:paddingRight="15dip" >
<TextView
android:id="@+id/tv1"
style="@style/TextViewMedStyleShadowWhite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="LIST 2"
android:textColor="@color/theme_blue" />
<ImageButton
android:id="@+id/addButton"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/ic_mini_add" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="5dip"
android:background="@color/theme_blue" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listView2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:divider="@null"
android:paddingLeft="10dip"
android:paddingRight="10dip" />
<ProgressBar
android:id="@+id/progres2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
여기에는 두 개의 ListView가 있습니다. 지금 내 긴 클릭 리스너에 내가 항목이
listView2.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
View selectedView = listView2.getChildAt(arg2);
selectedView.setVisibility(View.INVISIBLE);
mCellIsMobile = true;
return false;
}
});
listView2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int xPos = (int)event.getX();
int yPos = (int)event.getY();
Log.i("Touched","ListView2"+xPos+" , "+yPos);
parentLayout.requestDisallowInterceptTouchEvent(false);
parentLayout.onInterceptTouchEvent(event);
return false;
}
});
또한 parentLayout는 또한 터치 리스너를 가지고 있지만 아이가 그것을 소비로 터치 부모를 결코 도달하지를 클릭 숨 깁니다. You want to drop item at a SPECIFIC place on second listview
코드 아래에만 두 번째 목록의 END 또는 중 하나를 목록의 시작을 추가 :
parentLayout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int xPos = (int)event.getX();
int yPos = (int)event.getY();
Log.i("Touched","Parent"+xPos+" , "+yPos);
return false;
}
});
덕분에 전체 프로젝트를 확인 적어도이 시작하는 것이 좋다. 나중에 특정 위치에 떨어지도록 구현할 수 있습니다. –