更新时间:2023-11-20 11:34:10
notifyDataSetChanged
不是ListAdapter
的方法,而是BaseAdapter
的方法(ArrayAdapter是BaseAdapter的子类).要解决此问题,您只需投射ListAdapter
notifyDataSetChanged
is not a method of ListAdapter
, but of BaseAdapter
, (ArrayAdapter is a subclass of BaseAdapter). To fix you can simply cast the ListAdapter
theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s1 = String.valueOf(parent.getItemAtPosition(position));
pe.remove(s1);
((BaseAdapter)theAdapter).notifyDataSetChanged();