我用notifyDataSetChanged
适配器,但我的列表没有更新。这是我的代码的一部分。适配器notifyDataSetChanged也不工作
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,userNames);
list = (ListView) findViewById(R.id.listViewUsers);
list.setAdapter(adapter);
所以每次我加入项目userNames
时间,我打电话adapter.notifyDataSetChanged();
方法,但目前还没有任何更新。我尝试了许多清洁工作,清除userNames
但它不起作用。 任何人都可以帮助我吗? 感谢
编辑:
我打电话给这两个函数在那里我添加新用户。
userNames.add(user.getUsername());
adapter.notifyDataSetChanged();
我也有User
类,但我填写ListView
与用户的用户名。
请出示更多的代码,您更改您的用户名? – Eugene
感谢您的回复,我做了一个编辑 –