Example usage for android.widget AutoCompleteTextView setCompletionHint

List of usage examples for android.widget AutoCompleteTextView setCompletionHint

Introduction

In this page you can find the example usage for android.widget AutoCompleteTextView setCompletionHint.

Prototype

public void setCompletionHint(CharSequence hint) 

Source Link

Document

Sets the optional hint text that is displayed at the bottom of the the matching list.

Usage

From source file:com.robwilliamson.healthyesther.fragment.dialog.AbstractAddNamedDialogFragment.java

@Override
public void onResume() {
    super.onResume();

    View view = Utils.checkNotNull(getView());
    Context context = Utils.checkNotNull(view.getContext());
    getNameTitle().setText(context.getText(valueNameId()));

    AutoCompleteTextView name = getNameTextView();
    name.setCompletionHint(getView().getContext().getText(valueCompletionHintId()));
    name.addTextChangedListener(new TextWatcher() {
        @Override// w w w  . j  a v  a  2  s  . c  om
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String text = s.toString();
            AbstractAddNamedDialogFragment.this.newNameEntered(text);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    name.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String suggestion = (String) parent.getAdapter().getItem(position);
            AbstractAddNamedDialogFragment.this.suggestionSelected(suggestion, mSuggestions.get(suggestion));
        }
    });
    getOkButton().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onOk();
            dismiss();
        }
    });

    if (contentLayoutId() != null && !mInflatedContent) {
        View.inflate(getView().getContext(), contentLayoutId(), getContentArea());
        mInflatedContent = true;
    }

    updateSuggestionAdapter();
}