當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.OnEditorActionListener方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:23,代碼來源:AbstractEditComponent.java

示例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);
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:10,代碼來源:DataBindingAdapters.java

示例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;
        }
    };
}
 
開發者ID:wulkanowy,項目名稱:wulkanowy,代碼行數:13,代碼來源:LoginActivity.java

示例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();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:69,代碼來源:EditorView.java

示例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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:55,代碼來源:ManualActivity.java


注:本文中的android.widget.TextView.OnEditorActionListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。