EditSlideTextActivitypublic class EditSlideTextActivity extends android.app.Activity This activity provides the function to edit the text content of given slide. |
Fields Summary |
---|
public static final String | SLIDE_INDEX | public static final String | SLIDE_TOTAL | public static final String | TEXT_CONTENT | private android.widget.TextView | mLabel | private android.widget.Button | mDone | private android.widget.EditText | mText | private int | mCurSlide | private int | mTotal | private android.os.Bundle | mState | private static final String | STATE | private final android.view.View.OnKeyListener | mOnKeyListener | private final android.view.View.OnClickListener | mOnDoneClickListener |
Methods Summary |
---|
protected void | editDone()
// Set result to parent, and close window.
setResult(RESULT_OK, new Intent(mText.getText().toString()));
finish();
| protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_slide_text);
String text;
if (icicle == null) {
// Get extra from intent.
Intent intent = getIntent();
mCurSlide = intent.getIntExtra(SLIDE_INDEX, 1);
mTotal = intent.getIntExtra(SLIDE_TOTAL, 1);
text = intent.getStringExtra(TEXT_CONTENT);
} else {
mState = icicle.getBundle(STATE);
mCurSlide = mState.getInt(SLIDE_INDEX, 1);
mTotal = mState.getInt(SLIDE_TOTAL, 1);
text = mState.getString(TEXT_CONTENT);
}
// Label.
mLabel = (TextView) findViewById(R.id.label);
mLabel.setText("Edit text for slide " + (mCurSlide + 1) + "/" + mTotal);
// Input text field.
mText = (EditText) findViewById(R.id.text);
mText.setText(text);
mText.setOnKeyListener(mOnKeyListener);
// Done button.
mDone = (Button) findViewById(R.id.done);
mDone.setOnClickListener(mOnDoneClickListener);
| protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
mState = new Bundle();
mState.putInt(SLIDE_INDEX, mCurSlide);
mState.putInt(SLIDE_TOTAL, mTotal);
mState.putString(TEXT_CONTENT, mText.getText().toString());
outState.putBundle(STATE, mState);
|
|