use of android.widget.TextView.OnEditorActionListener in project AndroidChromium by JackyAndroid.
the class PassphraseDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.sync_enter_passphrase, null);
TextView promptText = (TextView) v.findViewById(R.id.prompt_text);
promptText.setText(getPromptText());
TextView resetText = (TextView) v.findViewById(R.id.reset_text);
resetText.setText(getResetText());
resetText.setMovementMethod(LinkMovementMethod.getInstance());
resetText.setVisibility(View.VISIBLE);
mVerifyingTextView = (TextView) v.findViewById(R.id.verifying);
mPassphraseEditText = (EditText) v.findViewById(R.id.passphrase);
mPassphraseEditText.setHint(R.string.sync_enter_custom_passphrase_hint);
mPassphraseEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NEXT) {
handleSubmit();
}
return false;
}
});
// Create a new background Drawable for the passphrase EditText to use when the user has
// entered an invalid potential password.
// https://crbug.com/602943 was caused by modifying the Drawable from getBackground()
// without taking a copy.
mOriginalBackground = mPassphraseEditText.getBackground();
mErrorBackground = mOriginalBackground.getConstantState().newDrawable();
mErrorBackground.mutate().setColorFilter(ApiCompatibilityUtils.getColor(getResources(), R.color.input_underline_error_color), PorterDuff.Mode.SRC_IN);
final AlertDialog d = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme).setView(v).setPositiveButton(R.string.submit, new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
// We override the onclick. This is a hack to not dismiss the dialog after
// click of OK and instead dismiss it after confirming the passphrase
// is correct.
}
}).setNegativeButton(R.string.cancel, this).setTitle(R.string.sign_in_google_account).create();
d.getDelegate().setHandleNativeActionModesEnabled(false);
d.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
handleSubmit();
}
});
}
});
return d;
}
use of android.widget.TextView.OnEditorActionListener in project newsrob by marianokamp.
the class SubscribeFeedActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.subscribe_feed);
progressMonitor = findViewById(R.id.progress);
listView = (ListView) findViewById(R.id.discovered_feeds_list);
empty = findViewById(R.id.empty);
query = (EditText) findViewById(R.id.query);
Button searchButton = (Button) findViewById(R.id.search_button);
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
initiateSearch();
}
});
query.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
initiateSearch();
return true;
}
});
// TEXT & SUBJECT are available per se
if (getIntent().hasExtra(Intent.EXTRA_TEXT)) {
query.setText(getIntent().getStringExtra(Intent.EXTRA_TEXT));
searchButton.performClick();
}
}
use of android.widget.TextView.OnEditorActionListener in project greenDAO by greenrobot.
the class NoteActivity method setUpViews.
protected void setUpViews() {
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerViewNotes);
//noinspection ConstantConditions
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
notesAdapter = new NotesAdapter(noteClickListener);
recyclerView.setAdapter(notesAdapter);
addNoteButton = findViewById(R.id.buttonAdd);
//noinspection ConstantConditions
addNoteButton.setEnabled(false);
editText = (EditText) findViewById(R.id.editTextNote);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
addNote();
return true;
}
return false;
}
});
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
boolean enable = s.length() != 0;
addNoteButton.setEnabled(enable);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
use of android.widget.TextView.OnEditorActionListener in project android-delicious by lexs.
the class LoginActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
usernameView = (EditText) findViewById(R.id.username);
passwordView = (EditText) findViewById(R.id.password);
// Enable user to press enter when done
passwordView.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
handleLogin();
return true;
} else {
return false;
}
}
});
View loginButton = findViewById(R.id.login);
loginButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleLogin();
}
});
errorDrawable = DeliciousApplication.getErrorDrawable();
// Do we already have an account?
if (DeliciousAccount.get(this) != null) {
Toast.makeText(this, R.string.toast_account_exists, Toast.LENGTH_SHORT).show();
finish();
}
}
use of android.widget.TextView.OnEditorActionListener in project KeepScore by nolanlawson.
the class DialogHelper method showAdditionalDeltasDialog.
public static void showAdditionalDeltasDialog(boolean positive, final ResultListener<Integer> resultListener, final Context context) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.delta_popup, null);
prepareDeltaView(view, context);
final EditText editText = (EditText) view.findViewById(android.R.id.edit);
// highlight by
editText.setSelection(0, editText.getText().length());
// default for
// easier
// deletion
final AlertDialog adlg = new AlertDialog.Builder(context).setCancelable(true).setTitle(positive ? R.string.title_add : R.string.title_subtract).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (resultListener != null) {
if (!doCalculation(editText))
return;
int result = IntegerUtil.parseIntOrZero(editText.getText());
resultListener.onResult(result);
}
dialog.dismiss();
}
}).setNeutralButton(R.string.button_customize, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent intent = new Intent(context, SettingsActivity.class);
intent.putExtra(SettingsActivity.EXTRA_SCROLL_TO_CONFIGURATIONS, true);
context.startActivity(intent);
}
}).setNegativeButton(android.R.string.cancel, null).setView(view).create();
editText.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
if (!doCalculation(editText))
return true;
if (resultListener != null) {
int result = IntegerUtil.parseIntOrZero(editText.getText());
resultListener.onResult(result);
}
adlg.dismiss();
return true;
}
return false;
}
});
adlg.show();
}
Aggregations