You might find this helpful: http://moazzam-khan.com/blog/?p=58
On Dec 20, 2:18 am, koushi <[email protected]> wrote: > Hi guys, > > i have some problem to getting url from database > so any one help me...... > i have listview in my rssReader i want to when i click the list view > then go to the database get the url and display the rss feeds...... > > Here is my code...... > > protected void onListItemClick(ListView l, View v, int position, long > id) { > super.onListItemClick(l, v, position, id); > Intent i = new Intent(this, RSSReader.class); > > i.putExtra(NewsDbAdapter.KEY_ROWID, id); > startActivityForResult(i, ACTIVITY_VIEW); > > } > > This is RSSReader.java > > ackage com.android.worldnews; > > import java.net.MalformedURLException; > import java.net.URL; > > import javax.xml.parsers.SAXParser; > import javax.xml.parsers.SAXParserFactory; > > import org.w3c.dom.Text; > import org.xml.sax.InputSource; > import org.xml.sax.XMLReader; > > import android.app.Activity; > import android.content.Intent; > import android.os.Bundle; > import android.view.View; > import android.widget.AdapterView; > import android.widget.ArrayAdapter; > import android.widget.Button; > import android.widget.EditText; > import android.widget.ListView; > import android.widget.TextView; > import android.widget.AdapterView.OnItemClickListener; > > public class RSSReader extends Activity implements OnItemClickListener > { > > @SuppressWarnings("unused") > private static final int ACTIVITY_DESCRIPTION = 0; > > private static final int position = 0; > // private static final String MY_RSS = "NewsDbAdapter.KEY_ROWID"; > private static final String MY_RSS="http://www.ibnlive.com/xml/rss/ > sports.xml";//this is my default value i want to get my databse..... > please help me > private String FeedURL; > private RSSFeed feed = null; > private EditText mFeedURLText; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > feed = getFeed(MY_RSS); > UpdateDisplay(); > > } > > @SuppressWarnings("unchecked") > /*public void onItemClick(AdapterView parent, View v, int position, > long id) { > > Intent i = new Intent(this,ShowDescription.class); > RSSItem item = feed.getItem(position); > > i.putExtra("title", item.getTitle()); > i.putExtra("description", item.getDescription()); > i.putExtra("link", item.getLink()); > i.putExtra("pubdate", item.getPubdate()); > > startActivityForResult(i, ACTIVITY_DESCRIPTION); > } > */ > private void UpdateDisplay() { > TextView feedDescription=(TextView) findViewById > (R.id.feeddescription); > TextView feedTitle = (TextView) findViewById(R.id.feedtitle); > TextView feedPubdate = (TextView) findViewById(R.id.feedpubdate); > //ExpandableListView itemList=(ExpandableListView)findViewById > (R.id.itemlist); > ListView itemList = (ListView) findViewById(R.id.itemlist); > > if (feed == null) { > feedTitle.setText("No RSS Feed Available"); > return; > } > > feedTitle.setText(feed.getTitle()); > feedPubdate.setText(feed.getPubdate()); > feedDescription.setText(feed.getDescription()); > > ArrayAdapter<RSSItem> adapter = new ArrayAdapter<RSSItem>(this, > android.R.layout.simple_expandable_list_item_1, > feed.getAllItems()); > > itemList.setAdapter(adapter); > itemList.setSelection(0); > itemList.setOnItemClickListener(this); > > } > > private RSSFeed getFeed(String urlToRssFeed) { > try { > URL url = new URL(urlToRssFeed); > > SAXParserFactory factory = SAXParserFactory.newInstance(); > SAXParser parser = factory.newSAXParser(); > > XMLReader xmlReader = parser.getXMLReader(); > RSSHandler rssHandler = new RSSHandler(); > xmlReader.setContentHandler(rssHandler); > > InputSource is = new InputSource(url.openStream()); > xmlReader.parse(is); > > return rssHandler.getFeed(); > } catch (Exception e) { > e.printStackTrace(); > return null; > } > } > > @Override > public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long > arg3) { > // TODO Auto-generated method stub > > } > > please help me anyone i want this --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

