Java Code Examples for android.widget.AutoCompleteTextView#setOnFocusChangeListener()

The following examples show how to use android.widget.AutoCompleteTextView#setOnFocusChangeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onEndIconChanged(@NonNull TextInputLayout textInputLayout, int previousIcon) {
  AutoCompleteTextView editText = (AutoCompleteTextView) textInputLayout.getEditText();
  if (editText != null && previousIcon == TextInputLayout.END_ICON_DROPDOWN_MENU) {
    // Remove any listeners set on the edit text.
    editText.removeTextChangedListener(exposedDropdownEndIconTextWatcher);
    if (editText.getOnFocusChangeListener() == onFocusChangeListener) {
      editText.setOnFocusChangeListener(null);
    }
    editText.setOnTouchListener(null);
    if (IS_LOLLIPOP) {
      editText.setOnDismissListener(null);
    }
  }
}
 
Example 2
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@SuppressLint("ClickableViewAccessibility") // There's an accessibility delegate that handles
// interactions with the dropdown menu.
private void setUpDropdownShowHideBehavior(@NonNull final AutoCompleteTextView editText) {
  // Set whole layout clickable.
  editText.setOnTouchListener(
      new OnTouchListener() {
        @Override
        public boolean onTouch(@NonNull View v, @NonNull MotionEvent event) {
          if (event.getAction() == MotionEvent.ACTION_UP) {
            if (isDropdownPopupActive()) {
              dropdownPopupDirty = false;
            }
            showHideDropdown(editText);
          }
          return false;
        }
      });
  editText.setOnFocusChangeListener(onFocusChangeListener);
  if (IS_LOLLIPOP) {
    editText.setOnDismissListener(
        new OnDismissListener() {
          @Override
          public void onDismiss() {
            dropdownPopupDirty = true;
            dropdownPopupActivatedAt = System.currentTimeMillis();
            setEndIconChecked(false);
          }
        });
  }
}