Android AutoCompleteTextView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AutoCompleteTextView class.

This code example shows how to use the following methods:getText
                          items));
  } 
   
  public void onTextChanged(CharSequence s, int start, int before,
                              int count) {
    selection.setText(edit.getText());
  } 
   
  public void beforeTextChanged(CharSequence s, int start,
                                  int count, int after) {
    // needed for interface, but not used 
  } 
   
  public void afterTextChanged(Editable s) {
    // needed for interface, but not used 
  } 
} 
7
CodeRank
This code example shows how to use the following methods:getText
  } 
   
  @Override 
  public void onTextChanged(CharSequence s, int start, int before,
                              int count) {
    selection.setText(edit.getText());
  } 
   
  @Override 
  public void beforeTextChanged(CharSequence s, int start,
                                  int count, int after) {
    // needed for interface, but not used 
  } 
   
  @Override 
  public void afterTextChanged(Editable s) {
    // needed for interface, but not used 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:setOnKeyListener, setAdapter, setOnItemClickListener, setThreshold, addTextChangedListener
	public StationSelectorAdapter( Context context, AutoCompleteTextView view, StationSearchService service, List<Station> history, ChangeListener listener ) {
		this.context = context;
		this.listener = listener;
		this.history = history;
 
		view.setAdapter( new StationsAdapter( context, service, history ) );
		view.setMaxLines( 1 );
		view.setThreshold( 1 );
		view.addTextChangedListener( this );
		view.setOnItemClickListener( this );
		view.setOnKeyListener( this );
	} 
 
	@Override 
	public void afterTextChanged( Editable paramEditable ) {
		station = null;
		listener.stationChanged();
	} 
 
	@Override 
5
CodeRank
This code example shows how to use the following methods:setAdapter, setOnItemClickListener
 
    @Override 
    public void onResume() { 
        super.onResume(); 
        if (App.getUser().isSearchSuggestionsEnabled()) { 
            searchField.setAdapter(suggestionHelper.getAdapter());
            searchField.setOnItemClickListener(this);
        } else { 
            searchField.setAdapter(suggestionHelper.getEmptyAdapter());
        } 
    } 
 
    @Override 
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (v.getId() == R.id.query_input && actionId == EditorInfo.IME_NULL) {
            startSearch(); 
        } 
        return false; 
    } 
 
6
CodeRank
This code example shows how to use the following methods:requestFocus, setVisibility, setAdapter, setThreshold, setText
	} 
	 
	public void pulsaBuscar(View view){
		botonBuscar.setVisibility(View.INVISIBLE);
		titleConsulta.setVisibility(View.GONE);		
		textoBuscar.setVisibility(View.VISIBLE);
		textoBuscar.setText("");
		textoBuscar.requestFocus();
 
		// AutoComplete 
		S.data_base.openR(); 
		String[] aditivos = S.data_base.consultaNombreNummeroAditivos();
		S.data_base.close(); 
		if(aditivos == null)
			aditivos = new String[0];
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, aditivos);
		textoBuscar.setAdapter(adapter);
		textoBuscar.setThreshold(2);
	} 
	 

6
CodeRank
This code example shows how to use the following methods:getParent, removeView, getText, setText
	public List<String> getItems() {
		return items;
	} 
	 
	public String getText() {
		return EDIT_TEXT.getText().toString();
	} 
	 
	@Override 
	public void setText(String text) {
		super.setText(text);
		EDIT_TEXT.setText(text);
	} 
	 
	public void setItems(String[] items) {
		setItems(Arrays.asList(items));
	} 
	 
	public void setItems(List<String> items) {
		this.items = items;

6
CodeRank
This code example shows how to use the following methods:getAdapter, isPopupShowing, setAdapter, getText
        mFilterAdapter.onClick(view);
    } 
 
    @Override 
    public void onClick(View v) {
        if (mAutoCompleteTextView != null && !mAutoCompleteTextView.isPopupShowing()) {
            filterOnString(mAutoCompleteTextView.getText().toString());
        } 
    } 
 
    // This method will set the adapter if no adapter has been set.  The adapter is initialized 
    // here to prevent the drop-down from appearing uninvited on orientation change, as the 
    // AutoCompleteTextView.setText() will trigger the drop-down if the adapter has been set. 
    private void filterOnString(String string) {
        if (mAutoCompleteTextView.getAdapter() == null) {
            mAutoCompleteTextView.setAdapter(mFilterAdapter);
        } 
        mHideFilterSearchOnStart = false;
        mFilterAdapter.getFilter().filter(string);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getBottom, getLeft, getTop, getDropDownHorizontalOffset, getDropDownVerticalOffset
 
    @Override 
    public void onWindowFocusChanged(boolean hasFocus) {
        // TODO Auto-generated method stub 
        super.onWindowFocusChanged(hasFocus);
        Log.d("auto", "##########3 textView.getTop(): " + textView.getTop()
                + ", textView.getBottom()" + textView.getBottom()
                + ",textView.getLeft(): " + textView.getLeft());
        // textView.setDropDownVerticalOffset(textView.getBottom()); 
        // textView.setDropDownHorizontalOffset(textView.getLeft()); 
 
        Log.d("auto", "##########textView.getDropDownVerticalOffset(): " +
                textView.getDropDownVerticalOffset()
                + ", textView.getDropDownHorizontalOffset()" + textView.getDropDownHorizontalOffset());
 
    } 
 
    static final String[] COUNTRIES = new String[] {
            "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", 
            "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", 
6
CodeRank
This code example shows how to use the following methods:setInputType, setRawInputType, setSingleLine
This code example shows how to use the following methods:getParent, removeView, setText
  } 
 
  @Override 
  protected void onBindDialogView(View view) {
    AutoCompleteTextView editText = mEditText;
    editText.setText(getText());
 
    ViewParent oldParent = editText.getParent();
    if (oldParent != view) {
      if (oldParent != null) {
        ((ViewGroup) oldParent).removeView(editText);
      } 
      onAddEditTextToDialogView(view, editText);
    } 
  } 
 
  @Override 
  protected void onDialogClosed(boolean positiveResult) {
    if (positiveResult) {
      String value = mEditText.getText().toString();
5
CodeRank

Related Android AutoCompleteTextView Questions & Answers:

Other Android AutoCompleteTextView Examples

1:	// Get a reference to the AutoCompleteTextView in the layout
2:	AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
3:	// Get the string array
4:	String[] countries = getResources().getStringArray(R.array.countries_array);
-
1:	// Get a reference to the AutoCompleteTextView in the layout
2:	AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
3:	// Get the string array
4:	String[] countries = getResources().getStringArray(R.array.countries_array);

Read More

See Code Examples for Android AutoCompleteTextView Methods: