を使用してリスト内の項目を簡単に削除する方法はありonLongPress
ますか?
使用したいOnGestureListener
-リスト内のアイテムonLongPress
をリッスンしlongpress
て削除し、それに応じてアダプターで更新します。
私の問題は、カスタムアダプターを使用するonlistItemclick
と、onItemLongClick
競合とロングクリックがトリガーされないことです!
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(listmodified.this, "A long click detected", Toast.LENGTH_SHORT).show();
if (e.getAction()==MotionEvent.ACTION_DOWN)
{
OnItemLongClickListener itemDelListener = new OnItemLongClickListener(){
//@Override
public boolean onItemLongClick(AdapterView<?> parent, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub
itemSelected=parent.getItemAtPosition(position).toString();
adapter.remove(itemSelected);
myList.remove(position);
adapter.notifyDataSetChanged();
Toast.makeText(listmodified.this, "IN LONGCLICK", Toast.LENGTH_SHORT).show();
return false;
}};
longClickedItem = -1;
}