拖放排序列表视图项点击不起作用 [英] drag-sort-list-view item click does not work
本文介绍了拖放排序列表视图项点击不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 DragSortListView 库。它工作正常 - 拖放从我的列表视图中删除的项目,但我也想点击的ListView项目。当我设置OnClickListener它不工作。可能是什么问题?对不起,我的英文不好
I use DragSortListView library. It works fine - drag and remove items from my listview, but i also want to click ListView items. When I set OnClickListener it don't work. What could be the problem? Sorry for my bad english
我的片段:
private DragSortListView listView;
private MakeSingleBetAdapter adapter;
private View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
MyLog.d(TAG, "onCreateView");
BugSenseHandler.initAndStartSession(getActivity(), APP_Parameters.BugSense);
view = inflater.inflate(R.layout.fragment_make_single_bet,
container, false);
listView = (DragSortListView) view.findViewById(R.id.makeBetList);
listView.setRemoveListener(this);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(getActivity(), "Click: " + position, Toast.LENGTH_SHORT).show();
}
});
cursor = dbHelper.getAllBets();
adapter = new MakeSingleBetAdapter(getActivity(), cursor, 3, dbHelper);
listView.setAdapter(adapter);
return view;
}
@Override
public void remove(int which) {
Cursor cursorId = (Cursor) (listView.getItemAtPosition(which));
String id = cursorId.getString(cursor
.getColumnIndex(DBHelper.COL_BET_ID));
dbHelper.deleteBetById(id);
adapter.swapCursor(dbHelper.getAllBets());
}
我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/ch.bettings"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical" >
....
<com.mobeta.android.dslv.DragSortListView
android:id="@+id/makeBetList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/View1"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:cacheColorHint="@color/slidingMenu"
android:divider="#b5b5b5"
app:drag_enabled="true"
app:drag_start_mode="onMove"
app:remove_enabled="true"
app:remove_mode="flingRemove"
app:sort_enabled="false" />
....
</RelativeLayout>
如果我在适配器添加ClickListener - 它工作的很好,但我不能拖列表项
If I add ClickListener in my adapter - it work's fine, but I can not drag list items
推荐答案
尝试添加这些到你的列表视图行:
Try adding these to your listview row:
android:focusable="false"
android:focusableInTouchMode="false"
这篇关于拖放排序列表视图项点击不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文