Home | History | Annotate | Download | only in xmladapters
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.xmladapters;
     18 
     19 import android.app.ListActivity;
     20 import android.net.Uri;
     21 import android.os.Bundle;
     22 import android.widget.AdapterView.OnItemClickListener;
     23 
     24 /**
     25  * This example demonstrate the creation of a simple RSS feed reader using the XML adapter syntax.
     26  * The different elements of the feed are extracted using an {@link XmlDocumentProvider} and are
     27  * binded to the different views. An {@link OnItemClickListener} is also added, which will open a
     28  * browser on the associated news item page.
     29  */
     30 public class RssReaderActivity extends ListActivity {
     31     private static final String FEED_URI = "http://feeds.nytimes.com/nyt/rss/HomePage";
     32 
     33     @Override
     34     protected void onCreate(Bundle savedInstanceState) {
     35         super.onCreate(savedInstanceState);
     36 
     37         setContentView(R.layout.rss_feeds_list);
     38         setListAdapter(Adapters.loadCursorAdapter(this, R.xml.rss_feed,
     39                 "content://xmldocument/?url=" + Uri.encode(FEED_URI)));
     40 
     41         getListView().setOnItemClickListener(new UrlIntentListener());
     42     }
     43 }
     44