我在我的应用程序中同时使用SwipeRefreshLayout和AsyncTask。我知道,如果我要两次使用AsyncTask,则必须创建一个新实例来使所有程序运行。但是,当我按如下方式进行操作时,该过程将卡住,并且不会刷新数据。滑动按钮会永远持续下去。
这里是Function.java:
public interface AsyncResponse {
void processFinish(String output1, String output2, String output3, String output4, String output5, String output6,
String output7, String output8, String output9, String output10, String output11, String output12,
String output13, String output14, String output15, String output16, String output17, String output18,
String output19, String output20, String output21, String output22, String output23, String output24);
}
public static class placeIdTask extends AsyncTask<String, Void, JSONObject> {
public AsyncResponse delegate = null; //Call back interface
public placeIdTask(AsyncResponse asyncResponse) {
delegate = asyncResponse; //Assigning call back interface through constructor
}
@Override
protected JSONObject doInBackground(String... params) {
JSONObject jsonWeather = null;
try {
jsonWeather = getWeatherJSON();
} catch (Exception e) {
Log.d("Error", "Cannot process JSON results", e);
}
return jsonWeather;
}
我是SwipeRefreshLayout以及Java和Android的新手,在理解文档时遇到了困难。谁能帮我吗?提前致谢。
一只萌萌小番薯
相关分类