Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I correctly show data after fetching from server?
    primarykey
    data
    text
    <p>I am making an app in which I am retrieving some data from server and then showing it to user.It involve following steps:</p> <ol> <li>A list of names is showing to user in ListView. <br></li> <li>User click on any ListView item. <br></li> <li>Fetch the NID of the item clicked and then I invoke an AsyncTask class where I fetch the data from server according to NID. <br></li> <li>In AsyncTask class onPreExecute method I show an dialog to user indicating data is fetching.<br></li> <li>Now I parse all data and put it in an Bean Class object. <br></li> <li>In onPostExecute method I start an another Activity(nextactivity) and pass all data to this activity with Parcelable Intent. <br></li> <li>Dismiss the dialog. <br></li> <li>Now in onCreate method of this Activity(nextactivity) I show the data. </li> </ol> <p>But here problem is that as data is large Activity(nextactivity) taking more time to load and ListView activity is shown to the user for 2-3 sec then nextActivty is shown to the user.</p> <p>Here I am also giving you my code:</p> <p>This is the method from which I invoke AsyncTask class to fetch data:</p> <pre><code>@Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long id) { Toast toast = Toast.makeText(getApplicationContext(), "Item " + (position + 1) + ": " + rowItems.get(position).getNid(), Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); if(rowItems.get(position).getNid()!=null){ String[] params=new String[1]; params[0]=rowItems.get(position).getNid(); new RepresentativeDataAsynTask(RespresentativeList.this).execute(params); } </code></pre> <p>This is the AsyncTask class where I fetch all data:</p> <pre><code>@Override protected void onPreExecute() { proDialog = new ProgressDialog(mContext); proDialog.setTitle("Support Manager"); proDialog.setMessage("Fetching Details ..."); proDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); proDialog.setIcon(R.drawable.ic_launcher); proDialog.show(); super.onPreExecute(); } @Override protected RepresentativeData doInBackground(String... params) { JSONObject result = null; RepresentativeData representativeDetails = new RepresentativeData(); try { result = client.reprentativeDetailNode(mContext.getString(R.string.Server),params[0]); //fetching all data by parsing result } catch (ClientProtocolException e) { error=true; e.printStackTrace(); } catch (IOException e) { error=true; e.printStackTrace(); } return representativeDetails; } @Override protected void onPostExecute(RepresentativeData result) { Intent yourRepresentative = new Intent(mContext,YourRepresentative.class); yourRepresentative.putExtra("representative detail", result); proDialog.dismiss(); mContext.startActivity(yourRepresentative); } super.onPostExecute(result); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload