FileDocCategorySizeDatePackage
SimpleInputActivity.javaAPI DocAndroid 1.5 API3232Wed May 06 22:42:46 BST 2009com.android.im.app

SimpleInputActivity

public class SimpleInputActivity extends android.app.Activity

Fields Summary
public static final String
EXTRA_TITLE
public static final String
EXTRA_PROMPT
public static final String
EXTRA_DEFAULT_CONTENT
public static final String
EXTRA_OK_BUTTON_TEXT
android.widget.TextView
mPrompt
android.widget.EditText
mEdit
android.widget.Button
mBtnOk
android.widget.Button
mBtnCancel
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        setTheme(android.R.style.Theme_Dialog);
        setContentView(R.layout.simple_input_activity);

        Bundle extras = getIntent().getExtras();

        CharSequence title = extras.getCharSequence(EXTRA_TITLE);
        if (title != null) {
            setTitle(title);
        } else {
            setTitle(R.string.default_input_title);
        }

        CharSequence prompt = extras.getCharSequence(EXTRA_PROMPT);
        mPrompt = (TextView) findViewById(R.id.prompt);
        if (prompt != null) {
            mPrompt.setText(prompt);
        } else {
            mPrompt.setVisibility(View.GONE);
        }

        mEdit = (EditText) findViewById(R.id.edit);
        CharSequence defaultText = extras.getCharSequence(EXTRA_DEFAULT_CONTENT);
        if (defaultText != null) {
            mEdit.setText(defaultText);
        }

        mBtnOk = (Button) findViewById(R.id.btnOk);
        mBtnOk.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                setResult(RESULT_OK,
                        (new Intent()).setAction(mEdit.getText().toString()));
                finish();
            }
        });
        CharSequence okText = extras.getCharSequence(EXTRA_OK_BUTTON_TEXT);
        if (okText != null) {
            mBtnOk.setText(okText);
        }

        mBtnCancel = (Button) findViewById(R.id.btnCancel);
        mBtnCancel.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });

        // XXX Hack from GoogleLogin.java. The android:layout_width="fill_parent"
        // defined in the layout xml doesn't seem to work for LinearLayout.
        getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);