Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen using ArrayAdaptor in Android, The data isn't shown
    primarykey
    data
    text
    <p>I'm writing an Android App that loads in data from an RSS Feed and lists the available items, and their description. There are 2 instances in which I use ArrayAdaptor. One works and one does not. The first one lists available feeds (right now the feed URLs are hard coded), and that one works. MainActivity.java</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main); UpdateDisplay(); } private void UpdateDisplay() { ListView itemlist = (ListView) findViewById(R.id.itemlist); java.util.ArrayList&lt;String&gt; channels = new java.util.ArrayList&lt;String&gt;(); for(int i=0;i&lt;RSS_FEEDS.length;i++){ channels.add(RSS_FEEDS[i][0]); } ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, channels); itemlist.setAdapter(adapter); itemlist.setOnItemClickListener(this); } </code></pre> <p>The second ArrayAdaptor is used in another Activity that the first generates by selecting a feed to view. The RSSFeed is parsed, and it returns valid data (I have tested it outside of teh android environment, and it worked, recompiled it in android, and it still works, so the RSSParser is not the issue). RSSFeed.java </p> <pre><code>public void onCreate(Bundle b){ super.onCreate(b); setContentView(R.layout.feedlayout); UpdateDisplay(); } private void UpdateDisplay() { String feedUrl = null; Intent startingIntent = getIntent(); if(startingIntent != null){ Bundle args = startingIntent.getBundleExtra("android.intent.extra.INTENT"); if(args != null){ feedUrl = args.getString("URL"); feedTitle = args.getString("title"); }else{ feedTitle = "No Available RSS Feed"; } }else{ feedTitle = "Error finding parent Intent"; } ListView lv = (ListView)findViewById(R.id.storylist); if(feedUrl != null){ // Get Feed Items RSSFeed feed = getFeed(feedUrl); ArrayList&lt;String&gt; values = loadItems(feed); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,values); lv.setAdapter(adapter); lv.setOnItemClickListener(this); } TextView title = (TextView)this.findViewById(R.id.feedtitle); title.setText(feedTitle); Button backbutton = (Button)findViewById(R.id.backbutton_2); backbutton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { finish(); } }); } </code></pre> <p>I'm using the android.R.layout.simple_list_item_1 layout in both places, but it only works in the first. The backbutton Button also isn't displayed for some reason. Here's the feedlayout.xml file </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/feedtitle" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;ListView android:id="@+id/storylist" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;Button android:id="@+id/backbutton_2" android:text="Back" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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