package com.rss_reader;
//Download by http://www.codefans.net
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
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.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;
import com.rss_reader.data.RSSFeed;
import com.rss_reader.data.RSSItem;
import com.rss_reader.sax.RSSHandler;
public class ActivityMain extends Activity implements OnItemClickListener
{
// public final String RSS_URL = "http://rubyjin.cn/blog/rss";
public final String RSS_URL = "http://feed.feedsky.com/yeeyan_top";
public final String tag = "RSSReader";
private RSSFeed feed = null;
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
feed = getFeed(RSS_URL);
showListView();
}
private RSSFeed getFeed(String urlString)
{
try
{
URL url = new URL(urlString);
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 ee)
{
return null;
}
}
private void showListView()
{
ListView itemlist = (ListView) findViewById(R.id.itemlist);
if (feed == null)
{
setTitle("访问的RSS无效");
return;
}
SimpleAdapter adapter = new SimpleAdapter(this, feed.getAllItemsForListView(),
android.R.layout.simple_list_item_2, new String[] { RSSItem.TITLE,RSSItem.PUBDATE },
new int[] { android.R.id.text1 , android.R.id.text2});
itemlist.setAdapter(adapter);
itemlist.setOnItemClickListener(this);
itemlist.setSelection(0);
}
public void onItemClick(AdapterView parent, View v, int position, long id)
{
Intent itemintent = new Intent(this,ActivityShowDescription.class);
Bundle b = new Bundle();
b.putString("title", feed.getItem(position).getTitle());
b.putString("description", feed.getItem(position).getDescription());
b.putString("link", feed.getItem(position).getLink());
b.putString("pubdate", feed.getItem(position).getPubDate());
itemintent.putExtra("android.intent.extra.rssItem", b);
startActivityForResult(itemintent, 0);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Android 手机系统的rss reader源代码
共31个文件
class:12个
java:6个
xml:4个
3星 · 超过75%的资源 需积分: 9 21 下载量 22 浏览量
2011-11-07
19:24:36
上传
评论 1
收藏 44KB RAR 举报
温馨提示
Android 手机系统的阅读器rss reader源代码,一个很棒的程序,RSS 阅读器相信大家都清楚吧,专用于RSS定阅,在电脑上已是一个成熟的应用了,本RSS Reader是运行在Google的Android手机操作系统中,对此有研究的专业人士不要错过源代码。
资源推荐
资源详情
资源评论
收起资源包目录
rss_reader.rar (31个子文件)
codefans.net
rss_reader
AndroidManifest.xml 704B
res
layout
showdescription.xml 629B
main.xml 376B
drawable
icon.png 3KB
源码爱好者.url 133B
values
strings.xml 177B
src
com
rss_reader
ActivityMain.java 3KB
data
RSSFeed.java 1KB
RSSItem.java 1KB
ActivityShowDescription.java 1KB
sax
源码爱好者.url 133B
RSSHandler.java 2KB
bin
com
rss_reader
data
RSSFeed.class 2KB
RSSItem.class 2KB
ActivityShowDescription.class 2KB
sax
RSSHandler.class 3KB
ActivityMain.class 4KB
R.class 503B
R$layout.class 421B
R$attr.class 328B
R$id.class 433B
R$string.class 415B
ActivityShowDescription$1.class 845B
R$drawable.class 388B
classes.dex 10KB
resources.ap_ 6KB
rss_reader.apk 13KB
.classpath 280B
default.properties 960B
.project 846B
gen
com
rss_reader
R.java 897B
共 31 条
- 1
资源评论
- wqss10202012-11-09不能用啊,
- mion_seu2012-07-01同楼上,不太好用。求指导
- meitianainid2014-04-03基本上没什么帮助
- 天才冬冬2012-06-12不知道为什么,项目图表上总是有个叉号,总是提示项目有错误无法运行。包什么的都导入了
- jisilx2012-11-08不能用 还那么多分
勾月禅心
- 粉丝: 685
- 资源: 6702
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功