Search in sources :

Example 26 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project platform_frameworks_base by android.

the class RenameDocumentFragment method onCreateDialog.

/**
     * Creates the dialog UI.
     * @param savedInstanceState
     * @return
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    mEditText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_rename);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            renameDocuments(mEditText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                renameDocuments(mEditText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 27 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project AndroidChromium by JackyAndroid.

the class LoginPrompt method createDialog.

private void createDialog() {
    View v = LayoutInflater.from(mContext).inflate(R.layout.http_auth_dialog, null);
    mUsernameView = (EditText) v.findViewById(R.id.username);
    mPasswordView = (EditText) v.findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                mDialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();
                return true;
            }
            return false;
        }
    });
    TextView explanationView = (TextView) v.findViewById(R.id.explanation);
    explanationView.setText(mAuthHandler.getMessageBody());
    mDialog = new AlertDialog.Builder(mContext, R.style.AlertDialogTheme).setTitle(R.string.login_dialog_title).setView(v).setPositiveButton(R.string.login_dialog_ok_button_label, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            mAuthHandler.proceed(getUsername(), getPassword());
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            mAuthHandler.cancel();
        }
    }).setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            mAuthHandler.cancel();
        }
    }).create();
    mDialog.getDelegate().setHandleNativeActionModesEnabled(false);
    // Make the IME appear when the dialog is displayed if applicable.
    mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
Also used : KeyEvent(android.view.KeyEvent) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 28 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project AndroidChromium by JackyAndroid.

the class PassphraseCreationDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.sync_custom_passphrase, null);
    mEnterPassphrase = (EditText) view.findViewById(R.id.passphrase);
    mConfirmPassphrase = (EditText) view.findViewById(R.id.confirm_passphrase);
    mConfirmPassphrase.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                tryToSubmitPassphrase();
            }
            return false;
        }
    });
    TextView instructionsView = (TextView) view.findViewById(R.id.custom_passphrase_instructions);
    instructionsView.setMovementMethod(LinkMovementMethod.getInstance());
    instructionsView.setText(getInstructionsText());
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme).setView(view).setTitle(R.string.sync_passphrase_type_custom_dialog_title).setPositiveButton(R.string.save, null).setNegativeButton(R.string.cancel, null).create();
    dialog.getDelegate().setHandleNativeActionModesEnabled(false);
    return dialog;
}
Also used : KeyEvent(android.view.KeyEvent) AlertDialog(android.support.v7.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 29 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project ActionBarSherlock by JakeWharton.

the class AstroboyMasterConsole method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // @Inject, @InjectResource, and @InjectExtra injection happens during super.onCreate()
    super.onCreate(savedInstanceState);
    sayText.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            // Have the remoteControl tell Astroboy to say something
            remoteControl.say(textView.getText().toString());
            textView.setText(null);
            return true;
        }
    });
    brushTeethButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            remoteControl.brushTeeth();
        }
    });
    selfDestructButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            // Self destruct the remoteControl
            vibrator.vibrate(2000);
            remoteControl.selfDestruct();
        }
    });
    // Fighting the forces of evil deserves its own activity
    fightEvilButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            startActivity(new Intent(AstroboyMasterConsole.this, FightForcesOfEvilActivity.class));
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Intent(android.content.Intent) ContentView(roboguice.inject.ContentView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) View(android.view.View)

Example 30 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android_frameworks_base by AOSPA.

the class RenameDocumentFragment method onCreateDialog.

/**
     * Creates the dialog UI.
     * @param savedInstanceState
     * @return
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    mEditText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_rename);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            renameDocuments(mEditText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                renameDocuments(mEditText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Aggregations

OnEditorActionListener (android.widget.TextView.OnEditorActionListener)37 KeyEvent (android.view.KeyEvent)32 TextView (android.widget.TextView)32 View (android.view.View)28 DialogInterface (android.content.DialogInterface)13 LayoutInflater (android.view.LayoutInflater)13 EditText (android.widget.EditText)13 OnClickListener (android.view.View.OnClickListener)12 AlertDialog (android.app.AlertDialog)11 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Intent (android.content.Intent)9 Test (org.junit.Test)6 ContentResolver (android.content.ContentResolver)5 Button (android.widget.Button)4 InjectView (roboguice.inject.InjectView)4 Handler (android.os.Handler)3 AlertDialog (android.support.v7.app.AlertDialog)3 InputMethodManager (android.view.inputmethod.InputMethodManager)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3