का उपयोग करते समय ट्रिगर नहीं किया जाता है, मैं कार्ल बाउर (https://github.com/bauerca/drag-sort-listview) द्वारा उत्कृष्ट ड्रैग-सॉर्ट-लिस्टव्यू का उपयोग कर रहा हूं। ड्रैग-सॉर्ट सक्षम सूचीदृश्य को लागू करने के लिए। हालांकि, मेरी आवश्यकता सूची में ड्रैग हैंडल की आवश्यकता नहीं है, बल्कि इसके बजाय उपयोगकर्ता को आइटम का उपयोग करके सूची आइटम खींचने की अनुमति देने के लिए।setOnItemLongClickListener और setOnItemClickListener ड्रैग-सॉर्ट-लिस्टव्यू (DSLV)
मैं उस आइटम को काम करने के लिए प्राप्त कर लिया है, @ id/drag संपत्ति को सूची आइटम में ही सेट करके। हालांकि, यह आइटमक्लिक और आइटम LongClick घटनाओं का जवाब नहीं देने का दुष्प्रभाव है।
कोई अलग ड्रैगगेबल लेआउट के बिना आइटम क्लिक/लंबे क्लिक को काम करने के लिए कोई तरीका है?
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.myproject"
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
dslv:collapsed_height="1dp"
dslv:drag_scroll_start="0.33"
dslv:max_drag_scroll_speed="0.5" />
ItemView.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_box"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"/>
<TextView
android:id="@+id/drag"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:padding="@dimen/list_padding"
android:gravity="center_vertical" />
</LinearLayout>
Activity.java:
DragSortListView listView = (DragSortListView) view.findViewById(R.id.list);
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.makeText(arg0.getContext(), ((TextView)arg1).getText(), Toast.LENGTH_SHORT).show();
return false;
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View itemView, int index,
long id) {
Toast.makeText(getView().getContext(), ((TextView)itemView).getText(), Toast.LENGTH_SHORT).show();
}
});
ListView.xml -
संदर्भ के लिए, मेरे कोड के नीचे की तरह दिखता है बोनस के रूप में, अगर कोई कर सकता है क्लिक/लांगक्लिक के अलावा एकाधिक-चयन को सक्षम करने में सहायता करें, इसकी बहुत सराहना की जाएगी।
धन्यवाद!