ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文

  メンテナンス 前画面に戻る

対象スレッド 件名: MyList.java
名前: lightbox
処理選択
パスワード

件名 MyList.java
名前 lightbox
コメント
@DIV
package com.example.listrss;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup;

public class MyList extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO 自動生成されたメソッド・スタブ
		super.onCreate(savedInstanceState);
		
		String url = "http://matome.naver.jp/feed/hot";
		@c:red(new MyTask)() {

			@Override
			protected void onPostExecute(Document result) {
				if ( result == null ) {
					return;
				}
				
				// ルート要素
				Element root = result.getDocumentElement();
				Log.i("MyList", root.getNodeName());		
				List<ListItem> listItems = new ArrayList<ListItem>();
				listItems.clear();

				NodeList node_list = root.getElementsByTagName("item");
				for( int i = 0; i < node_list.getLength(); i++ ) {
					
					NodeList nl = ((Element)node_list.item(i)).getElementsByTagName("title");
					Log.i("MyList", nl.item(0).getFirstChild().getNodeValue());		

					listItems.add(new ListItem(nl.item(0).getFirstChild().getNodeValue(),""));

				}

				MyList.this.setListAdapter(@c:red(new MyAdapter)(MyList.this, 0, listItems));
				
			}

		}.@c:red(execute)(url);

	}

}
@END