FileDocCategorySizeDatePackage
MyRssReader.javaAPI DocAndroid 1.5 API3741Wed May 06 22:41:08 BST 2009com.example.codelab.rssexample

MyRssReader

public class MyRssReader extends android.app.Activity

Fields Summary
android.widget.ListView
mRssList
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle savedInstanceState)
Called with the activity is first created.

        super.onCreate(savedInstanceState);
        
        // Load screen layout.
        setContentView(R.layout.main_screen);

//END_INCLUDE(1_1)
//BEGIN_INCLUDE(1_2)        
        // Load some simple values into the ListView
        mRssList = (ListView) findViewById(R.id.rssListView);
        mRssList.setAdapter(
                new ArrayAdapter<String>(
                        this, 
                        R.layout.list_element, 
                        new String[] { "Scientific American", "BBC", "The Onion", "Engadget" }));
//END_INCLUDE(1_2)
public booleanonCreateOptionsMenu(android.view.Menu menu)

        // Always call the superclass implementation to 
        // provide standard items.
        super.onCreateOptionsMenu(menu);
        
        menu.add(0, 0, "Start RSS Service", null);
        menu.add(0, 1, "Stop RSS Service", null);
        menu.add(0, 2, "Add New Feed", null);
        menu.add(0, 3, "Delete Feed", null);
        menu.add(0, 4, "Update All Feeds", null);
        
        return true;
    
public booleanonOptionsItemSelected(Menu.Item item)

        switch (item.getId()) {
            case 0:
                showAlert(null, "You clicked 'start'!", "ok", null, false, null);
                break;
            case 1:
                showAlert(null, "You clicked stop!", "ok", null, false, null);
                break;
            case 2:
                showAlert(null, "You clicked 'Add'!", "ok", null, false, null);
                break;
            case 3:
                showAlert(null, "You clicked 'Delete'!", "ok", null, false, null);
                break;
            case 4:
                showAlert(null, "You clicked 'Update'!", "ok", null, false, null);
                break;
            default:
                showAlert(null, "I have no idea what you clicked!", "ok", null, false, null);
                break;
        }
        return true;
    
public booleanonPrepareOptionsMenu(android.view.Menu menu)

        return true;
    
protected voidonSaveInstanceState(android.os.Bundle outState)

        int index = mRssList.getSelectedItemIndex();
        if(index > -1){
            outState.putInteger("lastIndexItem", index);
        }