在listview 使用的过程中进行刷新必不可免,一般使用notifyDataSetChanged(),但是有时候能局部刷新会更好.
private void doUpdate(int index) { int visiblePositon = listView.getFirstVisiblePosition(); if (index - visiblePositon >= 0) { View view = listView.getChildAt(index - visiblePositon); // 更新界面数据 TextView name = (TextView) view.findViewById(R.id.et_name); name.setText("Update Name"); //更新列表数据 list.get(index).setName("New Name"); } }
更多小技巧请点击: