refreshableview.setOnRefreshListener(new PullToRefreshListener(){
@Override
public void onRefresh() {
// TODO Auto-generated method stub
try{
Thread.sleep(3000);
}catch(InterruptedException e){
e.printStackTrace();
}
refreshableview.finishRefreshing();
}
}, 0);
RefreshableView中
public void setOnRefreshListener(PullToRefreshListener listener, int id) {
mListener = listener;
mId = id;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
只要明白了,什么是空指针异常,就知道怎么解决了?
在java中,更确切的说,应该是空引用异常,也就是一个对象,你没有给他分配内存,就开始使用这个对象,比如调用这个对象的方法,这时候,就会报空指针异常了。
怎么解决呢?很简单,不是没有分配内存吗,给他分配内存就行了。
怎么分配内存呢?也简单,初始化这个对象,这个对象分配了内存了。
如何初始化?你懂的...
知其所以然:NullPointerException 官方说明文档
/**
Thrown when an application attempts to use null in a
case where an object is required. These include:
Calling the instance method of a null object.
Accessing or modifying the field of a null object.
Taking the length of null as if it were an array.
Accessing or modifying the slots of null as if it
were an array.
Throwing null as if it were a Throwable
value.
Applications should throw instances of this class to indicate other illegal uses of the null object. * @author unascribed @version 1.20, 11/17/05 @since JDK1.0 */