Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting values of RSS Feed row item with a TextView in Android
    primarykey
    data
    text
    <p>I'm trying to build an Android app that displays a couple of RSS feeds, and I want to display the RSS feed with just titles and dates, and then have the user click on them to view the full story. At the moment I'm passing the RSS row values as intent extras from their row Textviews. However, I can't not have the story TextView but still get this data to pass as an intent extra. Here's the relevant bits of my code:</p> <pre><code>public class RSSFeedView extends ListActivity implements OnItemClickListener { Intent intent; private String thread; private RSSFeed feed = null; RSSHandler rh = new RSSHandler(); private MyRowAdapter myRowAdapter; private ArrayList&lt;RSSItem&gt; items; private final static String TAG = "MAD Assignment"; public String description; private ProgressDialog pbarDialog; /** Called when the activity is first created */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); intent = getIntent(); thread = intent.getStringExtra("thread"); StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // or .detectAll() for all detectable .penaltyLog().build()); items = new ArrayList&lt;RSSItem&gt;(); myRowAdapter = new MyRowAdapter(this); setListAdapter(myRowAdapter); new DownloadFilesTask().execute(thread); } class MyRowAdapter extends ArrayAdapter&lt;RSSItem&gt; { Activity context; MyRowAdapter (Activity context) { super(context, R.layout.rss, items); this.context=context; } public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; if(row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.rss, null); } RSSItem _item = items.get(position); TextView title = (TextView)row.findViewById(R.id.rssTitle); title.setText(_item.getTitle()); **TextView feed = (TextView)row.findViewById(R.id.itemlist); feed.setText(_item.getDescription());** //description = _item.getDescription(); TRY TO GET IT WORKING WITH JUST DATE AND TITLE!!!!!!!! TextView date = (TextView)row.findViewById(R.id.rssDate); String dateStr = ConvertToDate(_item.getPubDate()); date.setText(dateStr); row.setOnClickListener(new OnItemClickListener(position)); return (row); } } @Override public boolean onCreateOptionsMenu (Menu menu) { new MenuInflater(getApplication()).inflate(R.menu.rss_menu, menu); return (super.onCreateOptionsMenu(menu)); } @Override public boolean onOptionsItemSelected (MenuItem item) { switch (item.getItemId()) { case R.id.rss1: new DownloadFilesTask().execute(thread); break; } return super.onOptionsItemSelected(item); } private class DownloadFilesTask extends AsyncTask&lt;String, Integer, RSSFeed&gt; { @Override protected RSSFeed doInBackground(String... urls) { // TODO Auto-generated method stub feed = new RSSFeed(); try { feed = getFeed (urls[0]); } catch (Exception e) { feed = null; } return feed; } @Override protected void onCancelled() { // TODO Auto-generated method stub super.onCancelled(); } @Override protected void onPostExecute(RSSFeed _feed) { // TODO Auto-generated method stub super.onPostExecute(_feed); if (_feed!=null) { hideProgressBar(); Log.v(TAG,"onPostExecute"); for (RSSItem _item : _feed.getAllItems()) { // needed as items have to be explicitly added // for notifyDataSetChanged to work items.add(_item); } myRowAdapter.notifyDataSetChanged(); } else { showError(); } } @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); showProgressBar(); } @Override protected void onProgressUpdate(Integer... values) { // TODO Auto-generated method stub super.onProgressUpdate(values); } } private RSSFeed getFeed (String urlToRssFeed) { try { URL url = new URL(urlToRssFeed); SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); XMLReader xmlreader = parser.getXMLReader(); RSSHandler theRssHandler = new RSSHandler(); xmlreader.setContentHandler(theRssHandler); InputSource is = new InputSource(url.openStream()); xmlreader.parse(is); return theRssHandler.getFeed(); } catch (Exception e) { return null; } } private class OnItemClickListener implements OnClickListener { private int mPosition; OnItemClickListener(int position) { mPosition = position; } @Override public void onClick(View row) { // TODO Auto-generated method stub final String title = (String) ((TextView) row.findViewById(R.id.rssTitle)).getText(); final String date = (String) ((TextView) row.findViewById(R.id.rssDate)).getText(); **final String desc = (String) ((TextView) row.findViewById(R.id.itemlist)).getText();** //final String desc = description; Intent showDetailedIntent = new Intent(RSSFeedView.this, RSSDetailed.class); showDetailedIntent.putExtra("title", title); showDetailedIntent.putExtra("date", date); showDetailedIntent.putExtra("desc", desc); startActivity(showDetailedIntent); } } @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub } } </code></pre> <p>Then in my RSSDetailed class I just pull the intent extras. Any ideas on how to grab the data without outputting it in a TextView first? Thanks in advance!</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.
    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