注意Void与void不是一个
Void的定义代码:
public final class Void {
/**
* The {@link Class} object that represents the primitive type {@code void}.
*/
public static final Class<Void> TYPE = lookupType();
// Note: Void.TYPE can't be set to "void.class", since *that* is
// defined to be "java.lang.Void.TYPE";
@SuppressWarnings("unchecked")
private static Class<Void> lookupType() {
try {
Method method = Runnable.class.getMethod("run", EmptyArray.CLASS);
return (Class<Void>) method.getReturnType();
} catch (Exception e) {
throw new AssertionError(e);
}
}
private Void() {
}
}
使用Void代码:
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
pullListAdapter.addAll("刚添加的");
pullToRefreshListView.onRefreshComplete();
}
}.execute();