FileDocCategorySizeDatePackage
NewLocaleDialog.javaAPI DocAndroid 1.5 API3013Wed May 06 22:41:08 BST 2009com.android.customlocale

NewLocaleDialog

public class NewLocaleDialog extends android.app.Activity implements View.OnClickListener, View.OnKeyListener
Dialog to ask the user for a new locale.

Returns the locale code (e.g. "en_US") via an intent with a "locale" extra string and a "select" extra boolean.

Fields Summary
public static final String
INTENT_EXTRA_LOCALE
public static final String
INTENT_EXTRA_SELECT
private static final String
TAG
private static final boolean
DEBUG
private android.widget.Button
mButtonAdd
private android.widget.Button
mButtonAddSelect
private android.widget.EditText
mEditText
private boolean
mWasEmpty
Constructors Summary
Methods Summary
public voidonClick(android.view.View v)

        String locale = mEditText.getText().toString();
        boolean select = v == mButtonAddSelect;
        
        if (DEBUG) {
            Log.d(TAG, "New Locale: " + locale + (select ? " + select" : ""));
        }

        Intent data = new Intent(NewLocaleDialog.this, NewLocaleDialog.class);
        data.putExtra(INTENT_EXTRA_LOCALE, locale);
        data.putExtra(INTENT_EXTRA_SELECT, select);
        setResult(RESULT_OK, data);

        finish();
    
protected voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);

        setContentView(R.layout.new_locale);

        mEditText = (EditText) findViewById(R.id.value);
        mWasEmpty = true;

        mButtonAdd = (Button) findViewById(R.id.add);
        mButtonAdd.setOnClickListener(this);
        mButtonAdd.setEnabled(false);

        mButtonAddSelect = (Button) findViewById(R.id.add_and_select);
        mButtonAddSelect.setOnClickListener(this);
        mButtonAddSelect.setEnabled(false);
        
        mEditText.setOnKeyListener(this);
    
public booleanonKey(android.view.View v, int keyCode, android.view.KeyEvent event)

        boolean isEmpty = TextUtils.isEmpty(mEditText.getText());
        if (isEmpty != mWasEmpty) {
            mWasEmpty = isEmpty;
            
            mButtonAdd.setEnabled(!isEmpty);
            mButtonAddSelect.setEnabled(!isEmpty);
        }
        return false;