Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Endless loop Progress Dialog AsyncTask
    primarykey
    data
    text
    <p>I got an endless loading and my gridview is not showing. My xml web address is working and everything seems fine. Are there something wrong with my codes? I just modified some codes, im trying to learn Asynctask here. Please help me </p> <p>CustomizedListView.class</p> <pre><code> public class CustomizedListView extends Activity { // All static variables private ProgressDialog pDialog; static final String URL = "http://XXXXXX"; // XML node keys ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList; static final String KEY_SONG = "song"; // parent node static final String KEY_ID = "id"; static final String KEY_TITLE = "title"; static final String KEY_ARTIST = "artist"; static final String KEY_DURATION = "duration"; static final String KEY_THUMB_URL = "thumb_url"; static String IMAGE_POSITION; GridView grid; LazyAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); //StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); //StrictMode.setThreadPolicy(policy); songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); new loadGridView().execute(); grid = (GridView) findViewById(R.id.grid_view); grid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String title = ((TextView) view.findViewById(R.id.title)).getText().toString(); String artist = ((TextView) view.findViewById(R.id.artist)).getText().toString(); String url = ((TextView) view.findViewById(R.id.duration)).getText().toString(); // Starting new intent Intent in = new Intent(getApplicationContext(),SingleMenuItemActivity.class); in.getIntExtra(IMAGE_POSITION, position); in.putExtra(KEY_TITLE, title); in.putExtra(KEY_ARTIST, artist); in.putExtra(KEY_THUMB_URL,url); startActivity(in); } }); } class loadGridView extends AsyncTask&lt;String, String, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog( CustomizedListView.this); pDialog.setMessage("Loading websites ..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } @Override protected String doInBackground(String... args) { // updating UI from Background Thread XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(URL); // getting XML from URL Document doc = parser.getDomElement(xml); // getting DOM element NodeList nl = doc.getElementsByTagName(KEY_SONG); // looping through all song nodes &lt;song&gt; for (int i = 0; i &lt; nl.getLength(); i++) { // creating new HashMap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); Element e = (Element) nl.item(i); // adding each child node to HashMap key =&gt; value map.put(KEY_ID, parser.getValue(e, KEY_ID)); map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE)); map.put(KEY_ARTIST, parser.getValue(e, KEY_ARTIST)); map.put(KEY_DURATION, parser.getValue(e, KEY_DURATION)); map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL)); // adding HashList to ArrayList songsList.add(map); } return null; } @Override protected void onPostExecute(String args) { // dismiss the dialog after getting all products adapter=new LazyAdapter(CustomizedListView.this, songsList); grid.setAdapter(adapter); pDialog.dismiss(); } } } </code></pre>
    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.
    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