【发布时间】:2016-05-08 14:27:00
【问题描述】:
我有一个带有适配器的列表视图和一个数组列表:
contactArrayList= new ArrayList<String>();
listview = (ListView) findViewById(R.id.listView);
arrayAdapter = new ArrayAdapter (this, android.R.layout.simple_list_item_1, contactArrayList);
listview.setAdapter(arrayAdapter);
我的listview总是包含我的arraylist的内容,因为修改arraylist后,我总是调用arrayAdapter.notifyDataSetChanged();。现在,我怎样才能让用户从 ListView 中删除一个值,并从我的数组中删除它?我知道如何让用户从列表视图中删除一个项目,但现在我想在我的 ArrayList 中删除与该项目对应的字符串。我该怎么做?
【问题讨论】:
-
只需从数组列表中删除 rhe 项。
-
显示你现在要删除的代码
-
@JawadLeWywadi 但是我怎么知道他们要删除哪个项目
-
这取决于你想如何实现它。寻找 onitemclick 或 onlongitemclick...
标签: java android listview arraylist