且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:无法解决notifyDataSetChanged();安卓

更新时间: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();