Note that there are some explanatory texts on larger screens.

plurals
  1. POViewPager, ListView, and AsyncTask, first page blank, all data in the second page
    primarykey
    data
    text
    <p>There is a similar question here, <a href="https://stackoverflow.com/questions/9525279/activity-using-viewpager-pageradapter-and-asynctask-causes-a-blank-view">Activity using ViewPager, PagerAdapter and AsyncTask causes a blank view</a>, but my problem is more than that.</p> <p>I have a ViewPager that contains a ListView. This ListView is populated by an asyncTask. The listview displays the data, but not correctly. The first page is always blank, and the second page contains BOTH pages data.</p> <p>I've simplified my asynctask to be sure tit wasnt something there that was causing the issue.</p> <pre><code>@Override public Object instantiateItem(View pager, int position){ // Log.d("PAGER", Integer.toString(position)); ctx = pager.getContext(); v = new ListView(ctx); new CreateArrayListTask().execute(URLS[position]); ((ViewPager)pager).addView(v, 0); return v; } </code></pre> <p><strong>CreateArrayListTask</strong></p> <pre><code>private class CreateArrayListTask extends AsyncTask&lt;String, Void, ArrayList&lt;String&gt;&gt; { @Override protected ArrayList&lt;String&gt; doInBackground(String... params) { linkArray.add("Item 1"); linkArray.add("Item 2"); return linkArray; } </code></pre> <p><strong>onPostExecute</strong> </p> <pre><code>protected void onPostExecute(ArrayList&lt;String&gt; linkArray) { ArrayAdapter&lt;String&gt; a = new ArrayAdapter&lt;String&gt;(ctx, android.R.layout.simple_list_item_1, linkArray); v.setAdapter(a); </code></pre> <p><img src="https://i.stack.imgur.com/3IXtY.png" alt="enter image description here"></p>
    singulars
    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.
 

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