I am developing an app which is have rest API calls and 4 tabs using page sliding tab strip but my problem is when I move tabs from left to right it's too late to display page and struck for 5 to 8 seconds why? and here i'm using fragments. my app is simply like what's app.
Thanks in advance.`
class GetTasks extends AsyncTask<String, Void, String> {
protected void onPreExecute() {
progressBar.setVisibility(View.VISIBLE);
}
protected void onPostExecute(String response) {
progressBar.setVisibility(View.GONE);
if (response != null && response.length() > 0) {
try {
JSONArray jsonArray = new JSONArray(response);
if (jsonArray != null && jsonArray.length() > 0) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObj = jsonArray.getJSONObject(i);
Gson gson = new Gson();
Task task = gson.fromJson(jsonObj.toString(),Task.class);
tasklist.add(task);
}
}else{
nodata.setVisibility(View.VISIBLE);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
nodata.setVisibility(View.VISIBLE);
}
Collections.reverse(tasklist);
ListAdapter adapter = new ListAdapter(tasklist);
list_view.setAdapter(adapter);
}
@Override
protected String doInBackground(String... params) {
try {
String response = Util.excuteGet(params[0]);
return response;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}`