Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my ListView not Displaying?
    text
    copied!<p>I have a problem with a <code>ListView</code> that is not displaying. I get no error and background picture and other text are displaying but the <code>ListView</code> is not displaying. I can't find the error by debugging.</p> <p>Any clue what the problem is?</p> <pre><code>public class MainActivity extends Activity { List&lt;String&gt; sermon; List&lt;String&gt; links; ArrayAdapter&lt;String&gt; adapter; private ListView list; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list = (ListView) findViewById(R.id.listView); sermon = new ArrayList&lt;String&gt;(); links = new ArrayList&lt;String&gt;(); adapter = new ArrayAdapter&lt;String&gt;(MainActivity.this, android.R.layout.simple_list_item_1, sermon); new PostTask(this).execute("http://gibk.se/sample-page/predikningar/?podcast"); } public class PostTask extends AsyncTask&lt;String, Long, String&gt; { private Context context; public PostTask(Context context) { this.context = context; } private InputStream getInputStream(URL url) { try { return url.openConnection().getInputStream(); } catch (IOException e) { return null; } } @Override protected String doInBackground(String... params) { try { String url = params[0]; URL urls = new URL(url); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(false); XmlPullParser xmlParser = factory.newPullParser(); xmlParser.setInput(getInputStream(urls), "UTF_8"); boolean insideItem = false; int eventType = xmlParser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if (xmlParser.getName().equalsIgnoreCase("item")) { insideItem = true; } else if (xmlParser.getName().equalsIgnoreCase("title")) { if (insideItem) sermon.add(xmlParser.nextText()); } else if (xmlParser.getName().equalsIgnoreCase("guid")) { if (insideItem) links.add(xmlParser.nextText()); } } else if (eventType == XmlPullParser.END_TAG &amp;&amp; xmlParser.getName().equalsIgnoreCase("item")) { insideItem = false; } eventType = xmlParser.next(); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } } protected void onPostExecute(String result) { list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int position, long arg3) { Uri uri = Uri.parse(links.get(position)); String url = uri.toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } }); } } </code></pre>
 

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