本文整理汇总了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);
}