package com.bentonq.newsexpress;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class NewsListActivity extends Activity {

	private NewsUpdater mNewsUpdater;
	private ListView mNewsListView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mNewsListView = (ListView) findViewById(R.id.news_list);

		String url = new String(
				"http://news.163.com/special/00011K6L/rss_newstop.xml");
		mNewsUpdater = new NewsUpdater();
		mNewsUpdater.update(url, new NewsUpdater.UpdateListener() {

			@Override
			public void onNewsUpdated(List<News> news) {
				final List<News> fnews = news;
				
				mNewsListView.setAdapter(new BaseAdapter() {

					@Override
					public int getCount() {
						return fnews.size();
					}

					@Override
					public Object getItem(int arg0) {
						// TODO Auto-generated method stub
						return null;
					}

					@Override
					public long getItemId(int arg0) {
						// TODO Auto-generated method stub
						return 0;
					}

					@Override
					public View getView(int position, View convertView,
							ViewGroup parent) {
						LayoutInflater inflater = LayoutInflater
								.from(NewsListActivity.this);
						View view = inflater.inflate(R.layout.view_summary,
								parent, false);
						
						TextView textView = (TextView) view.findViewById(R.id.title);
						textView.setText(fnews.get(position).title);
						
						TextView summaryView = (TextView) view.findViewById(R.id.summary);
						summaryView.setText(fnews.get(position).summary);
						
						return view;
					}
				});
			}
		});

	}
}

@@ -80,16 +80,71 @@
 tivity;%0A
+import android.content.Intent;%0Aimport android.net.Uri;%0A
 import a
@@ -193,24 +193,57 @@
 utInflater;%0A
+import android.view.MotionEvent;%0A
 import andro
@@ -287,16 +287,51 @@
 wGroup;%0A
+import android.widget.AdapterView;%0A
 import a
@@ -745,16 +745,623 @@
 s_list);
+%0A%09%09mNewsListView%0A%09%09%09%09.setOnItemClickListener(new AdapterView.OnItemClickListener() %7B%0A%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public void onItemClick(AdapterView%3C?%3E parent, View view,%0A%09%09%09%09%09%09%09int position, long id) %7B%0A%09%09%09%09%09%09String link = (String) parent%0A%09%09%09%09%09%09%09%09.getItemAtPosition(position);%0A%09%09%09%09%09%09Intent intent = new Intent(Intent.ACTION_VIEW);%0A%09%09%09%09%09%09intent.setData(Uri.parse(link));%0A%09%09%09%09%09%09startActivity(intent);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D);%0A%09%09mNewsListView.setOnTouchListener(new View.OnTouchListener() %7B%0A%0A%09%09%09@Override%0A%09%09%09public boolean onTouch(View v, MotionEvent event) %7B%0A%09%09%09%09// TODO Auto-generated method stub%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%7D);
 %0A%0A%09%09Stri
@@ -1637,20 +1637,16 @@
 = news;%0A
-%09%09%09%09
 %0A%09%09%09%09mNe
@@ -1809,28 +1809,32 @@
 getItem(int 
-arg0
+position
 ) %7B%0A%09%09%09%09%09%09//
@@ -1835,60 +1835,39 @@
 %09%09%09%09
-// TODO Auto-generated method stub%0A%09%09%09%09%09%09return null
+return fnews.get(position).link
 ;%0A%09%09
@@ -1922,56 +1922,19 @@
 int 
-arg0) %7B%0A%09%09%09%09%09%09// TODO Auto-generated method stub
+position) %7B
 %0A%09%09%09
@@ -1943,17 +1943,24 @@
 %09return 
-0
+position
 ;%0A%09%09%09%09%09%7D
@@ -2223,30 +2223,24 @@
 nt, false);%0A
-%09%09%09%09%09%09
 %0A%09%09%09%09%09%09TextV
@@ -2261,32 +2261,41 @@
  (TextView) view
+%0A%09%09%09%09%09%09%09%09
 .findViewById(R.
@@ -2356,22 +2356,16 @@
 title);%0A
-%09%09%09%09%09%09
 %0A%09%09%09%09%09%09T
@@ -2401,16 +2401,25 @@
 ew) view
+%0A%09%09%09%09%09%09%09%09
 .findVie
@@ -2495,22 +2495,16 @@
 mmary);%0A
-%09%09%09%09%09%09
 %0A%09%09%09%09%09%09r

Add click function(Open in browser)