如何使AdapterView.OnItemClickListener()工作,
... activity implements View.OnLongClickListener, View.OnClickListener,
DragDropPresenter,
View.OnTouchListener { ... }
我有
public void onClick(View v) {
// TODO Auto-generated method stub
}
处理点击? 想法是长按一下就会激活拖放,只需短按即可使用OnItemClickListener方法。它甚至可能吗?
答案 0 :(得分:0)
您的问题有点简化,但我希望下面的例子会有所帮助:
public class MainActivity extends Activity implements OnClickListener, OnItemClickListener, OnItemLongClickListener {
....
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
.....
listView.setAdapter(adapter);
listView.setOnItemLongClickListener(this);
listView.setOnItemClickListener(this);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
.....
}
@Override
public boolean onItemLongClick (AdapterView<?> parent, View item, int position, long id) {
....
}
答案 1 :(得分:0)
通过为每个单元格分配一个标记,然后使用简单的onClick侦听器读取标记,克服了处理短暂点击的问题:
public void onClick(View v) {
Integer position = (Integer)v.getTag();
if (position = ...){ do some stuff }
}