android.widget.AutoCompleteTextView Java Examples

The following examples show how to use android.widget.AutoCompleteTextView. 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: StandardAutoCompleteSignInActivity.java    From input-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onAutofillEvent(@NonNull View view, int event) {
    if (view instanceof AutoCompleteTextView) {
        switch (event) {
            case AutofillManager.AutofillCallback.EVENT_INPUT_UNAVAILABLE:
                // no break on purpose
            case AutofillManager.AutofillCallback.EVENT_INPUT_HIDDEN:
                if (!mAutofillReceived) {
                    ((AutoCompleteTextView) view).showDropDown();
                }
                break;
            case AutofillManager.AutofillCallback.EVENT_INPUT_SHOWN:
                mAutofillReceived = true;
                ((AutoCompleteTextView) view).setAdapter(null);
                break;
            default:
                Log.d(TAG, "Unexpected callback: " + event);
        }
    }
}
 
Example #2
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onEditTextAttached(@NonNull TextInputLayout textInputLayout) {
  AutoCompleteTextView autoCompleteTextView =
      castAutoCompleteTextViewOrThrow(textInputLayout.getEditText());

  setPopupBackground(autoCompleteTextView);
  addRippleEffect(autoCompleteTextView);
  setUpDropdownShowHideBehavior(autoCompleteTextView);
  autoCompleteTextView.setThreshold(0);
  autoCompleteTextView.removeTextChangedListener(exposedDropdownEndIconTextWatcher);
  autoCompleteTextView.addTextChangedListener(exposedDropdownEndIconTextWatcher);
  textInputLayout.setEndIconCheckable(true);
  textInputLayout.setErrorIconDrawable(null);
  textInputLayout.setTextInputAccessibilityDelegate(accessibilityDelegate);

  textInputLayout.setEndIconVisible(true);
}
 
Example #3
Source File: AddSmsActivity.java    From SmsScheduler with GNU General Public License v2.0 6 votes vote down vote up
private boolean validateForm() {
    boolean result = true;
    if (sms.getTimestampScheduled() < GregorianCalendar.getInstance().getTimeInMillis()) {
        Toast.makeText(getApplicationContext(), getString(R.string.form_validation_datetime), Toast.LENGTH_SHORT).show();
        result = false;
    }
    if (TextUtils.isEmpty(sms.getRecipientNumber())) {
        ((AutoCompleteTextView) findViewById(R.id.form_input_contact)).setError(getString(R.string.form_validation_contact));
        result = false;
    }
    if (TextUtils.isEmpty(sms.getMessage())) {
        ((EditText) findViewById(R.id.form_input_message)).setError(getString(R.string.form_validation_message));
        result = false;
    }
    return result;
}
 
Example #4
Source File: MainActivity.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ActionBar actionBar = getActionBar();
    actionBar.setTitle(R.string.app_name);
    actionBar.setSubtitle(null);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setHomeButtonEnabled(false);

    fragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.main_fragment);

    search = (AutoCompleteTextView) findViewById(R.id.main_header_search);
    View line = findViewById(R.id.main_header_line);
    fragment.setSearch(search);
    fragment.setLine(line);
}
 
Example #5
Source File: TransferFragment.java    From EosCommander with MIT License 6 votes vote down vote up
@Override
protected void setUpView(View view) {

    mRootView = view;

    //  from, to, amount edit text
    AutoCompleteTextView etFrom = view.findViewById(R.id.et_from);
    AutoCompleteTextView etTo = view.findViewById(R.id.et_to);
    EditText etAmount = view.findViewById(R.id.et_amount);

    // click handler
    view.findViewById(R.id.btn_transfer).setOnClickListener(v -> onSend() );

    etAmount.setOnEditorActionListener((textView, actionId, keyEvent) -> {
        if (EditorInfo.IME_ACTION_SEND == actionId) {
            onSend();
            return true;
        }

        return false;
    });


    // account history
    UiUtils.setupAccountHistory( etFrom, etTo );
}
 
Example #6
Source File: ShowSearchFieldOnClickListener.java    From privacy-friendly-shopping-list with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item)
{
    TextInputLayout searchLayout = (TextInputLayout) activity.findViewById(R.id.search_input_layout);
    AutoCompleteTextView searchText = (AutoCompleteTextView) activity.findViewById(R.id.search_input_text);
    ImageButton cancel = (ImageButton) activity.findViewById(R.id.cancel_search);
    searchLayout.setVisibility(View.VISIBLE);
    cancel.setVisibility(View.VISIBLE);
    if ( searchText.requestFocus() )
    {
        showKeyboard();
    }
    AutoCompleteTextView searchAutoCompleteTextView = (AutoCompleteTextView) activity.findViewById(R.id.search_input_text);
    searchAutoCompleteTextView.setText(StringUtils.EMPTY);
    return true;
}
 
Example #7
Source File: PopupActivity.java    From ankihelper with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    View v = getCurrentFocus();
    boolean ret = super.dispatchTouchEvent(event);

    if (v instanceof AutoCompleteTextView) {
        View currentFocus = getCurrentFocus();
        int screenCoords[] = new int[2];
        currentFocus.getLocationOnScreen(screenCoords);
        float x = event.getRawX() + currentFocus.getLeft() - screenCoords[0];
        float y = event.getRawY() + currentFocus.getTop() - screenCoords[1];

        if (event.getAction() == MotionEvent.ACTION_UP
                && (x < currentFocus.getLeft() ||
                x >= currentFocus.getRight() ||
                y < currentFocus.getTop() ||
                y > currentFocus.getBottom())) {
            InputMethodManager imm =
                    (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
            v.clearFocus();
        }
    }
    return ret;
}
 
Example #8
Source File: CustomTypeface.java    From custom-typeface with Apache License 2.0 6 votes vote down vote up
/**
 * Register the theme attributes with the default style for all the views extending
 * {@link TextView} defined in Android SDK. You can use this method if you create an
 * instance of {@code CustomTypeface}, and you want to configure with the default
 * styles for the default android widgets.
 *
 * @param instance an instance of {@code CustomTypeface} to register the attributes
 * @see #registerAttributeForDefaultStyle(Class, int)
 */
public static void registerAttributesForDefaultStyles(CustomTypeface instance) {
    instance.registerAttributeForDefaultStyle(TextView.class, android.R.attr.textViewStyle);
    instance.registerAttributeForDefaultStyle(EditText.class, android.R.attr.editTextStyle);
    instance.registerAttributeForDefaultStyle(Button.class, android.R.attr.buttonStyle);
    instance.registerAttributeForDefaultStyle(AutoCompleteTextView.class,
            android.R.attr.autoCompleteTextViewStyle);
    instance.registerAttributeForDefaultStyle(CheckBox.class, android.R.attr.checkboxStyle);
    instance.registerAttributeForDefaultStyle(RadioButton.class,
            android.R.attr.radioButtonStyle);
    instance.registerAttributeForDefaultStyle(ToggleButton.class,
            android.R.attr.buttonStyleToggle);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        instance.registerAttributeForDefaultStyle(CheckedTextView.class,
                android.R.attr.checkedTextViewStyle);
    }
}
 
Example #9
Source File: PreferenceFragment.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void validationAvailable(List<String> items) {
    mUiHandler.post(() -> {
        List<Preference> list = getPreferenceList(getPreferenceScreen(), new ArrayList<>());
        for (Preference p : list) {
            if (p.getKey().endsWith(Constants.PREF_SUFFIX_ITEM) && p instanceof EditTextPreference) {
                final EditText editText = ((EditTextPreference) p).getEditText();

                if (editText instanceof AutoCompleteTextView) {
                    AutoCompleteTextView t = (AutoCompleteTextView) editText;
                    t.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, items));
                    t.performValidation();
                }
            }
        }
    });
}
 
Example #10
Source File: LoginActivity.java    From Car-Pooling with MIT License 6 votes vote down vote up
/**
 * This method is used to get values in displayed view and perform actions accordingly
 */

private void defineView(){
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    registerCheckBox = (CheckBox)findViewById(R.id.isRegister);
    mPasswordView = (EditText) findViewById(R.id.password);
    Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
    mEmailSignInButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptLogin();
           /* Intent myIntent = new Intent(view.getContext(), HomeActivity.class);
            startActivityForResult(myIntent, 0);
            finish();*/
        }
    });

    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
}
 
Example #11
Source File: SearchIssuesActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	BrowseConfig config = new BrowseConfig();
	
	config.typeFilter = "Public";
	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	if (radio.isChecked()) {
		config.typeFilter = "Personal";
	}
	Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin);
	config.sort = (String)sortSpin.getSelectedItem();
	AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText);
	config.tag = tagText.getText().toString();
	//AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	//config.category = categoryText.getText().toString();
	EditText filterEdit = (EditText)findViewById(R.id.filterText);
	config.filter = filterEdit.getText().toString();
	//CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox);
	//MainActivity.showImages = checkbox.isChecked();

	config.type = "Issue";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetIssuesAction(this, config);
	action.execute();
}
 
Example #12
Source File: SearchViewHacker.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void setHint(SearchView searchView, String hint, int resId, int color, Resources resources) {
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findView(searchView, "mQueryTextView");

    SpannableStringBuilder stopHint = new SpannableStringBuilder("");
    stopHint.append(hint);

    autoComplete.setHint(stopHint);
    autoComplete.setHintTextColor(color);
}
 
Example #13
Source File: PeliasSearchViewTest.java    From open with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void setAutoCompleteListView_shouldHideListViewWhenQueryLosesFocus() throws Exception {
    ListView listView = new ListView(ACTIVITY);
    listView.setVisibility(VISIBLE);
    peliasSearchView.setAutoCompleteListView(listView);
    AutoCompleteTextView queryText = getQueryTextView();
    shadowOf(queryText).setViewFocus(false);
    assertThat(listView).isGone();
}
 
Example #14
Source File: EditorView.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * 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.FullscreenWhiteDialog);
    mContext = activity;
    mObserverForTest = observerForTest;
    mHandler = new Handler();
    mPhoneFormatterTask = new AsyncTask<Void, Void, PhoneNumberFormattingTextWatcher>() {
        @Override
        protected PhoneNumberFormattingTextWatcher doInBackground(Void... unused) {
            return new PhoneNumberFormattingTextWatcher();
        }
    }.execute();

    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 instanceof AutoCompleteTextView) {
                    focusInputField(next);
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #15
Source File: SimpleStorageActivity.java    From ethereum-android-sample with Apache License 2.0 5 votes vote down vote up
private void writeValue() {
    AutoCompleteTextView valueTextview = (AutoCompleteTextView) findViewById(R.id.storage_input);
    final String value = valueTextview.getText().toString();
    if (TextUtils.isEmpty(value)) {
        valueTextview.setError(getString(R.string.error_field_required));
    } else {
        SharedPreferences prefs = getSharedPreferences(SIMPLE_STORAGE_PREFS, MODE_PRIVATE);
        final String contractAddress = prefs.getString(CONTRACT_ADDRESS, null);
        final SimpleOwnedStorage simpleOwnedStorage = ethereumAndroid.contracts().bind(contractAddress, CONTRACT_ABI, SimpleOwnedStorage.class);
        Runnable writeTask = new Runnable() {
            @Override
            public void run() {
                final PendingTransaction<Void> pendingWrite;
                try {
                    pendingWrite = simpleOwnedStorage.set(value);
                } catch (Exception e) {
                    showError(e);
                    return;
                }
                Runnable transactionTask = new Runnable() {
                    @Override
                    public void run() {
                        ethereumAndroid.submitTransaction(SimpleStorageActivity.this, REQUEST_CODE_WRITE, pendingWrite.getUnsignedTransaction());
                    }
                };
                SimpleStorageActivity.this.runOnUiThread(transactionTask);
            }
        };
        new Thread(writeTask, "write contract data thread").start();
    }
}
 
Example #16
Source File: MaterialDialog.java    From pius1 with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setContentView(View contentView)
{
           ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
	ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
           contentView.setLayoutParams(layoutParams);
           if (contentView instanceof ListView)
    {
               setListViewHeightBasedOnChildren((ListView) contentView);
           }
           LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
	R.id.message_content_view);
           if (linearLayout != null)
    {
               linearLayout.removeAllViews();
               linearLayout.addView(contentView);
           }
           for (int i = 0; i < (linearLayout != null ? linearLayout.getChildCount() : 0); i++)
    {
               if (linearLayout.getChildAt(i) instanceof AutoCompleteTextView)
	{
                   AutoCompleteTextView autoCompleteTextView
		= (AutoCompleteTextView) linearLayout.getChildAt(i);
                   autoCompleteTextView.setFocusable(true);
                   autoCompleteTextView.requestFocus();
                   autoCompleteTextView.setFocusableInTouchMode(true);
               }
           }
       }
 
Example #17
Source File: SearchPostsActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	BrowseConfig config = new BrowseConfig();
	
	config.typeFilter = "Public";
	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	if (radio.isChecked()) {
		config.typeFilter = "Personal";
	}
	Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin);
	config.sort = (String)sortSpin.getSelectedItem();
	AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText);
	config.tag = (String)tagText.getText().toString();
	AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	config.category = (String)categoryText.getText().toString();
	EditText filterEdit = (EditText)findViewById(R.id.filterText);
	config.filter = filterEdit.getText().toString();
	CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox);
	MainActivity.showImages = checkbox.isChecked();

	config.type = "Post";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetPostsAction(this, config);
	action.execute();
}
 
Example #18
Source File: SearchPostsActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	BrowseConfig config = new BrowseConfig();
	
	config.typeFilter = "Public";
	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	if (radio.isChecked()) {
		config.typeFilter = "Personal";
	}
	Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin);
	config.sort = (String)sortSpin.getSelectedItem();
	AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText);
	config.tag = (String)tagText.getText().toString();
	AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	config.category = (String)categoryText.getText().toString();
	EditText filterEdit = (EditText)findViewById(R.id.filterText);
	config.filter = filterEdit.getText().toString();
	CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox);
	MainActivity.showImages = checkbox.isChecked();

	config.type = "Post";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetPostsAction(this, config);
	action.execute();
}
 
Example #19
Source File: BrowserActivity.java    From JumpGo with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * method to generate search suggestions for the AutoCompleteTextView from
 * previously searched URLs
 */
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {

    mSuggestionsAdapter = new SuggestionsAdapter(this, mDarkTheme, isIncognito());

    getUrl.setThreshold(1);
    getUrl.setDropDownWidth(-1);
    getUrl.setDropDownAnchor(R.id.toolbar_layout);
    getUrl.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
            String url = null;
            CharSequence urlString = ((TextView) view.findViewById(R.id.url)).getText();
            if (urlString != null) {
                url = urlString.toString();
            }
            if (url == null || url.startsWith(getString(R.string.suggestion))) {
                CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
                if (searchString != null) {
                    url = searchString.toString();
                }
            }
            if (url == null) {
                return;
            }
            getUrl.setText(url);
            searchTheWeb(url);
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
            mPresenter.onAutoCompleteItemPressed();
        }

    });

    getUrl.setSelectAllOnFocus(true);
    getUrl.setAdapter(mSuggestionsAdapter);
}
 
Example #20
Source File: SearchView.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
private static void setText(AutoCompleteTextView view, CharSequence text, boolean filter) {
    try {
        Method method = AutoCompleteTextView.class.getMethod("setText", CharSequence.class, boolean.class);
        method.setAccessible(true);
        method.invoke(view, text, filter);
    } catch (Exception e) {
        //Fallback to public API which hopefully does mostly the same thing
        view.setText(text);
    }
}
 
Example #21
Source File: AutoCompleteActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String[] mCountries = getResources().getStringArray(R.array.country_names);

    // Get a reference to the AutoCompleteTextView
    final AutoCompleteTextView textView = findViewById(R.id.autocomplete_country);

    // Create an ArrayAdapter containing country names
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
            R.layout.list_item, mCountries);

    // Set the adapter for the AutoCompleteTextView
    textView.setAdapter(adapter);

    // Display a Toast Message when the user clicks on an item in the AutoCompleteTextView
    textView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                                long arg3) {
            Toast.makeText(getApplicationContext(),
                    getString(R.string.winner_is_string, arg0.getAdapter().getItem(arg2)),
                    Toast.LENGTH_LONG).show();
            textView.setText("");
        }
    });
}
 
Example #22
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void setPopupBackground(@NonNull AutoCompleteTextView editText) {
  if (IS_LOLLIPOP) {
    int boxBackgroundMode = textInputLayout.getBoxBackgroundMode();
    if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_OUTLINE) {
      editText.setDropDownBackgroundDrawable(outlinedPopupBackground);
    } else if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_FILLED) {
      editText.setDropDownBackgroundDrawable(filledPopupBackground);
    }
  }
}
 
Example #23
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Creating the instance of ArrayAdapter containing list of fruit names
    ArrayAdapter<String> adapter = new ArrayAdapter<String>
            (this, android.R.layout.select_dialog_item, fruits);
    //Getting the instance of AutoCompleteTextView
    AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
    actv.setThreshold(1);//will start working from first character
    actv.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView
    actv.setTextColor(Color.RED);

}
 
Example #24
Source File: SearchView.java    From zen4android with MIT License 5 votes vote down vote up
private static void ensureImeVisible(AutoCompleteTextView view, boolean visible) {
    try {
        Method method = AutoCompleteTextView.class.getMethod("ensureImeVisible", boolean.class);
        method.setAccessible(true);
        method.invoke(view, visible);
    } catch (Exception e) {
        //Oh well...
    }
}
 
Example #25
Source File: DownLoadAddActivity.java    From FastDownloader with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_down_load_add);
    ButterKnife.bind(this, this);
    // Set up the url form.
    mUrlView = (AutoCompleteTextView) findViewById(R.id.down_Loadurl);
    mGoDownButton = (Button) findViewById(R.id.down_in_button);

}
 
Example #26
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
  final AutoCompleteTextView editText =
      castAutoCompleteTextViewOrThrow(textInputLayout.getEditText());
  editText.post(
      new Runnable() {
        @Override
        public void run() {
          boolean isPopupShowing = editText.isPopupShowing();
          setEndIconChecked(isPopupShowing);
          dropdownPopupDirty = isPopupShowing;
        }
      });
}
 
Example #27
Source File: ViewUtil.java    From material with Apache License 2.0 5 votes vote down vote up
/**
 * Apply any AutoCompleteTextView style attributes to a view.
 * @param v
 * @param attrs
 * @param defStyleAttr
 * @param defStyleRes
 */
private static void applyStyle(AutoCompleteTextView v,  AttributeSet attrs, int defStyleAttr, int defStyleRes){
    TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);

        if(attr == R.styleable.AutoCompleteTextView_android_completionHint)
            v.setCompletionHint(a.getString(attr));
        else if(attr == R.styleable.AutoCompleteTextView_android_completionThreshold)
            v.setThreshold(a.getInteger(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownAnchor)
            v.setDropDownAnchor(a.getResourceId(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHeight)
            v.setDropDownHeight(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownWidth)
            v.setDropDownWidth(a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownHorizontalOffset)
            v.setDropDownHorizontalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_dropDownVerticalOffset)
            v.setDropDownVerticalOffset(a.getDimensionPixelSize(attr, 0));
        else if(attr == R.styleable.AutoCompleteTextView_android_popupBackground)
            v.setDropDownBackgroundDrawable(a.getDrawable(attr));
    }
    a.recycle();
}
 
Example #28
Source File: DropdownMenuEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onPopulateAccessibilityEvent(View host, @NonNull AccessibilityEvent event) {
  super.onPopulateAccessibilityEvent(host, event);
  AutoCompleteTextView editText =
      castAutoCompleteTextViewOrThrow(textInputLayout.getEditText());

  if (event.getEventType() == TYPE_VIEW_CLICKED
      && accessibilityManager.isTouchExplorationEnabled()) {
    showHideDropdown(editText);
  }
}
 
Example #29
Source File: SearchPostsActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void browse(View view) {
	BrowseConfig config = new BrowseConfig();
	
	config.typeFilter = "Public";
	RadioButton radio = (RadioButton)findViewById(R.id.personalRadio);
	if (radio.isChecked()) {
		config.typeFilter = "Personal";
	}
	Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin);
	config.sort = (String)sortSpin.getSelectedItem();
	AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText);
	config.tag = (String)tagText.getText().toString();
	AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText);
	config.category = (String)categoryText.getText().toString();
	EditText filterEdit = (EditText)findViewById(R.id.filterText);
	config.filter = filterEdit.getText().toString();
	CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox);
	MainActivity.showImages = checkbox.isChecked();

	config.type = "Post";
	if (MainActivity.instance != null) {
		config.instance = MainActivity.instance.id;
	}
	
	HttpAction action = new HttpGetPostsAction(this, config);
	action.execute();
}
 
Example #30
Source File: MainActivity.java    From SearchView with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        empty = (LinearLayout) findViewById(R.id.empty);
        empty.setOnClickListener(this);
        search = (AutoCompleteTextView) findViewById(R.id.search);
        // 自动提示适配器
//        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, str);
        // 支持拼音检索
        SearchAdapter<String> adapter = new SearchAdapter<String>(MainActivity.this,
                android.R.layout.simple_list_item_1, str, SearchAdapter.ALL);
        search.setAdapter(adapter);
    }