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;
}
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);
}
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;
}
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));
}
});
}
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;
}
Aggregations