FileDocCategorySizeDatePackage
TitleEditor.javaAPI DocGoogle Android v1.5 Example3282Sun Nov 11 13:01:04 GMT 2007com.google.android.notepad

TitleEditor

public class TitleEditor extends android.app.Activity implements View.OnClickListener
An activity that will edit the title of a note. Displays a floating window with a text field.

Fields Summary
public static final String
EDIT_TITLE_ACTION
This is a special intent action that means "edit the title of a note".
private static final int
TITLE_INDEX
Index of the title column
private static final String[]
PROJECTION
An array of the columns we are interested in.
android.database.Cursor
mCursor
Cursor which will provide access to the note whose title we are editing.
android.widget.EditText
mText
The EditText field from our UI. Keep track of this so we can extract the text when we are finished.
Constructors Summary
Methods Summary
public voidonClick(android.view.View v)

        // When the user clicks, just finish this activity.
        // onPause will be called, and we save our data there.
        finish();
    
public voidonCreate(android.os.Bundle icicle)

    
    
        
        super.onCreate(icicle);

        setContentView(R.layout.title_editor);

        // Get the uri of the note whose title we want to edit
        ContentURI uri = getIntent().getData();

        // Get a cursor to access the note
        mCursor = managedQuery(uri, PROJECTION, null, null);

        // Set up click handlers for the text field and button
        mText = (EditText) this.findViewById(R.id.title);
        mText.setOnClickListener(this);
        
        Button b = (Button) findViewById(R.id.ok);
        b.setOnClickListener(this);
    
protected voidonPause()

        super.onPause();

        // Write the text back into the cursor 
        if (mCursor != null) {
            String title = mText.getText().toString();
            mCursor.updateString(TITLE_INDEX, title);
            mCursor.commitUpdates();
        }
    
protected voidonResume()

        super.onResume();

        // Initialize the text with the title column from the cursor
        if (mCursor != null) {
            mCursor.first();
            String title = mCursor.getString(TITLE_INDEX);
            mText.setText(title);
        }