调用了notifydatasetchanged方法后 listview数据加载成功但是画面不及时更新,要滚动一下屏幕才出来刷新的数据,求高手指点
listview 调用了notifydatasetchanged方法后 屏幕内容须通过下拉然后再返回来才能显出变化 ,在网上找了很长时间也不知道原因,请高手指点一下啊!
数据更新没有问题,就是显示不及时,相当于屏幕要滑动到别的地方再回来 才行。点击底部加载更多的时候,往下拉会看到数据,但是那个加载更多的按钮还是在原先的位置,没有跑到底下,画面没有更新,当把这个画面上下拉一下回来后 ,才看到想要的画面,
这个是我调用刷新的代码
private HuihuaAdapter ha;
public void onRefresh() {
mHandler.postDelayed(new Runnable() {
public void run() {
list.clear();
list.addAll(getHuahui());
// Toast toast = Toast.makeText(MainActivity.this, "接收到刷新指令"
// + list.size(), Toast.LENGTH_LONG);
// toast.show();
ha.list = list;
mPullDownView.onRefreshComplete();//这里表示刷新处理完成后把上面的加载刷新界面隐藏
mPullDownView.setMore(true);//这里设置true表示还有更多加载,设置为false底部将不显示更多
ha.notifyDataSetChanged();
}
}, 1500);
-------下面这个是HuihuaAdapter .java-------------------
public class HuihuaAdapter extends BaseAdapter {
private Context context;
public ArrayList<HuiHua> list = new ArrayList<HuiHua>();
public HuihuaAdapter(Context context,ArrayList<HuiHua> list){
this.context = context;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return list.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
HuiHua hh = list.get(position);
H h = null;
if(view==null){
h = new H();
view = LayoutInflater.from(context).inflate(R.layout.liaotian, parent, false);
//h.pic = (ImageView)view.findViewById(R.id.l1);
h.pic = (TextView)view.findViewById(R.id.l1);
h.name = (TextView)view.findViewById(R.id.name);
h.time = (TextView)view.findViewById(R.id.time);
h.lastmsg = (TextView)view.findViewById(R.id.lastmsg);
view.setTag(h);
}else{
h = (H)view.getTag();
}
//h.pic.setImageResource(Integer.parseInt(hh.getTxPath()));
//h.pic.setText(hh.getTxPath());
h.pic.setText(hh.getTxPath());
h.name.setText(hh.getName1());
h.time.setText(hh.getLastTime());
h.lastmsg.setText(hh.getLastContent());
//更换背景图片,getEndtime返回的值为1时,表示有效,否则则是无效过期的标识背景
if (hh.getEndtime().equals("1")) {
h.pic.setBackgroundResource(R.drawable.areabg1);
} else {
h.pic.setBackgroundResource(R.drawable.areabg2);
}
return view;
}
class H{
//ImageView pic;
TextView pic;
TextView name;
TextView time;
TextView lastmsg;
}
}
万望高手指点啊!