@ u013280307 谢谢您的回复
还想请问下:
在fragment里边: 当下拉更新的时候,会调用onRefresh() 函数:
当下拉更新的时候,比如说 设置的时间是5000, 但是当那个下拉更新的图标提示消失了,而 那个mChat.updatedata()里边数据还没有解析完,但是它是回调了这个onDone()函数了。
。。。。
mListView.setXListViewListener(new IXListViewListener(){
public void onRefresh() {
mmHandler.postDelayed(new Runnable() {
@Override
public void run() {
mChat.updatedata(null,new ChatCallBack(){
public void onDone(ListMemberInfo> list){
listdata.clear();
listdata= list;
Message mes = mHandler.obtainMessage(2);
mHandler.sendMessage(mes);
}
});
mListView.stopRefresh();
mListView.stopLoadMore();
}
}, 5000);
}
private final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
mGetAdapter = ChatGetAdapter(getActivity(),listdata);
mListView.setAdapter(mGetAdapter);
break;
case 2:
mGetAdapter.update(listdata);
break;
default:
break;
}
super.handleMessage(msg);
}
};
—————————————
在
public class GetAdapte extends BaseAdapter {
。。。。
public GetAdapte( Context context,List<MemberInfo>list ) {
super();
this.context = context;
layoutInflater = (LayoutInflater)context.getSystemService(inflater);
this.mberlist = list;
}
public void setmList( List<MemberInfo> mList) {
this.Memberlist = mList;
}
public void update(List<Info> list) {
setmList(list);
this.notifyDataSetChanged();
}
public View getView(int position,View convertView,ViewGroup parent ) {
。。。。。。。。。。。
}
}
还有一个问题是:上面的代码会出现以下错误提示:
请问 它是通过 sendmessage()然后在mGetAdapter.update(listdata); 这个应该怎么处理呢?
04-21 14:24:20.773: E/AndroidRuntime(9805): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131296482, class com.example.view.XListView) with Adapter(class android.widget.HeaderViewListAdapter)]
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.widget.ListView.layoutChildren(ListView.java:1566)
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.widget.AbsListView$CheckForTap.run(AbsListView.java:3807)
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.os.Handler.handleCallback(Handler.java:733)
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.os.Handler.dispatchMessage(Handler.java:95)
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.os.Looper.loop(Looper.java:157)
04-21 14:24:20.773: E/AndroidRuntime(9805): at android.app.ActivityThread.main(ActivityThread.java:5387)
04-21 14:24:20.773: E/AndroidRuntime(9805): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 14:24:20.773: E/AndroidRuntime(9805): at java.lang.reflect.Method.invoke(Method.java:515)
04-21 14:24:20.773: E/AndroidRuntime(9805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
04-21 14:24:20.773: E/AndroidRuntime(9805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
04-21 14:24:20.773: E/AndroidRuntime(9805): at dalvik.system.NativeStart.main(Native Method)