I'm making an RSS reader and I'm trying to add a way to change what feed it is viewing. So far I haven't been able to figure out how to change it.
Here's the part at the beginning of onCreate
And the code for the dialog, which is brought up through a menu.
I'm pretty sure that what I have is wrong (mostly because it didn't work) but Eclipse isn't giving me any errors.
Here's the part at the beginning of onCreate
Code:
private void readRss(){
feedTitle.setText("--- wait ---");
feedDescribtion.setText("");
feedPubdate.setText("");
feedLink.setText("");
setListAdapter(null);
Toast.makeText(this, "Reading RSS, Please wait.", Toast.LENGTH_LONG).show();
try {
URL rssUrl = new URL("http://feeds.feedburner.com/AndroidPhoneFans?format=xml");
SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
XMLReader myXMLReader = mySAXParser.getXMLReader();
RSSHandler myRSSHandler = new RSSHandler();
myXMLReader.setContentHandler(myRSSHandler);
InputSource myInputSource = new InputSource(rssUrl.openStream());
myXMLReader.parse(myInputSource);
And the code for the dialog, which is brought up through a menu.
Code:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
alert.setTitle("Set RSS URL");
alert.setMessage("Example: http://www.example.com/rss.xml");
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString().trim();
Toast.makeText(getApplicationContext(), value,
Toast.LENGTH_SHORT).show();
try {
new URL(value);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
alert.show();
I'm pretty sure that what I have is wrong (mostly because it didn't work) but Eclipse isn't giving me any errors.