本文整理匯總了Java中android.widget.TextView.OnEditorActionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.OnEditorActionListener方法的具體用法?Java TextView.OnEditorActionListener怎麽用?Java TextView.OnEditorActionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.OnEditorActionListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addEditorActionListener
import android.widget.TextView; //導入方法依賴的package包/類
protected final void addEditorActionListener(TextView.OnEditorActionListener listener) {
TextView view;
if (listener != null && (view = getHostView()) != null) {
if (mEditorActionListeners == null) {
mEditorActionListeners = new ArrayList<>();
view.setOnEditorActionListener(new TextView.OnEditorActionListener() {
private boolean handled = true;
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
for (TextView.OnEditorActionListener l : mEditorActionListeners) {
if (l != null) {
handled = handled & l.onEditorAction(v, actionId, event);
}
}
return handled;
}
});
}
mEditorActionListeners.add(listener);
}
}
示例2: setOnEditorActionListener
import android.widget.TextView; //導入方法依賴的package包/類
/**
* Facilitates binding editor action listeners on EditText fields.
*/
@BindingAdapter("onEditorAction")
public static void setOnEditorActionListener(
EditText layout,
TextView.OnEditorActionListener listener) {
layout.setOnEditorActionListener(listener);
}
示例3: getTextViewSignInListener
import android.widget.TextView; //導入方法依賴的package包/類
private TextView.OnEditorActionListener getTextViewSignInListener() {
return new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
};
}
示例4: EditorView
import android.widget.TextView; //導入方法依賴的package包/類
/**
* Builds the editor view.
*
* @param activity The activity on top of which the UI should be displayed.
* @param observerForTest Optional event observer for testing.
*/
public EditorView(Activity activity, PaymentRequestObserverForTest observerForTest) {
super(activity, R.style.FullscreenWhite);
mContext = activity;
mObserverForTest = observerForTest;
mHandler = new Handler();
mEditorActionListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
mDoneButton.performClick();
return true;
} else if (actionId == EditorInfo.IME_ACTION_NEXT) {
View next = v.focusSearch(View.FOCUS_FORWARD);
if (next != null) {
next.requestFocus();
return true;
}
}
return false;
}
};
mHalfRowMargin = activity.getResources().getDimensionPixelSize(
R.dimen.payments_section_large_spacing);
mFieldViews = new ArrayList<>();
mEditableTextFields = new ArrayList<>();
mDropdownFields = new ArrayList<>();
final Pattern cardNumberPattern = Pattern.compile("^[\\d- ]*$");
mCardNumberInputFilter = new InputFilter() {
@Override
public CharSequence filter(
CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
// Accept deletions.
if (start == end) return null;
// Accept digits, "-", and spaces.
if (cardNumberPattern.matcher(source.subSequence(start, end)).matches()) {
return null;
}
// Reject everything else.
return "";
}
};
mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher();
new AsyncTask<Void, Void, PhoneNumberFormattingTextWatcher>() {
@Override
protected PhoneNumberFormattingTextWatcher doInBackground(Void... unused) {
return new PhoneNumberFormattingTextWatcher();
}
@Override
protected void onPostExecute(PhoneNumberFormattingTextWatcher result) {
mPhoneFormatter = result;
if (mPhoneInput != null) {
mPhoneInput.addTextChangedListener(mPhoneFormatter);
}
}
}.execute();
}
示例5: onCreate
import android.widget.TextView; //導入方法依賴的package包/類
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.manPages = initPages();
ArrayAdapter<Page> manPagesAdapter = new ArrayAdapter<Page>(this,
android.R.layout.simple_list_item_1, manPages);
ArrayAdapter<Page> manPagesCompleteAdapter = new ArrayAdapter<Page>(
this, android.R.layout.simple_dropdown_item_1line, manPages);
// Main list of all manpages
ListView manPagesView = (ListView) findViewById(R.id.pages_names);
manPagesView.setAdapter(manPagesAdapter);
manPagesView.setOnItemClickListener(new OnManpageClickListener(this));
// List of manpages displayed in the text field suggestions
AutoCompleteTextView manPagesCompleteTextView = (AutoCompleteTextView) findViewById(R.id.search_input);
manPagesCompleteTextView.setAdapter(manPagesCompleteAdapter);
manPagesCompleteTextView
.setOnItemClickListener(new OnManpageClickListener(this));
// Check the availability of files on external storage
if (!checkPageFilesOnExternalStorage(null))
suggestDownload();
// Handle the Enter key in the TextView
// Get the input TextView
AutoCompleteTextView input = (AutoCompleteTextView) findViewById(R.id.search_input);
// Create a new handler for the Enter key ("Go" key here)
TextView.OnEditorActionListener enterKeyListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
// If search key was hit, search for this manpage
if (actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_NULL) {
Page p = getManpageCalled(v.getText().toString());
if (p != null) {
// display it if found,
displayManpage(p);
} else {
// else display an error message
Toast.makeText(getApplicationContext(),
"This manpage does not exist...",
Toast.LENGTH_LONG).show();
}
}
return true;
}
};
input.setOnEditorActionListener(enterKeyListener);
}