notifyDataSetChanged() 动态更新ListView

Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.


附示例代码:

//添加新的数据
mList.add(0, mEditText.getText().toString());
//通知UI主线程动态更新ListView
mAdapter.notifyDataSetChanged();
//添加数据成功后清空EditText
mEditText.setText("");


你可能感兴趣的:(Adapter,观察者)