当前位置: 首页>>代码示例>>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;未经允许,请勿转载。