android.widget.AutoCompleteTextView

Here are the examples of the java api class android.widget.AutoCompleteTextView taken from open source projects.

1. CreateInstanceActivity#onCreate()

Project: BotLibre
File: CreateInstanceActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_instance);
    resetView();
    final AutoCompleteTextView templateText = (AutoCompleteTextView) findViewById(R.id.templateText);
    templateText.setText(MainActivity.template);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, MainActivity.getAllTemplates(this));
    templateText.setThreshold(0);
    templateText.setAdapter(adapter);
    templateText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            templateText.showDropDown();
            return false;
        }
    });
}

2. CreateInstanceActivity#onCreate()

Project: BotLibre
File: CreateInstanceActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_instance);
    resetView();
    final AutoCompleteTextView templateText = (AutoCompleteTextView) findViewById(R.id.templateText);
    templateText.setText(MainActivity.template);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, MainActivity.getAllTemplates(this));
    templateText.setThreshold(0);
    templateText.setAdapter(adapter);
    templateText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            templateText.showDropDown();
            return false;
        }
    });
}

3. TextviewFragment#onActivityCreated()

Project: holoaccent
File: TextviewFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    String[] items = getResources().getStringArray(R.array.list_items);
    ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, items);
    AutoCompleteTextView autoCompleteTextView1 = (AutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
    autoCompleteTextView1.setAdapter(adapter1);
    ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, items);
    AutoCompleteTextView autoCompleteTextView2 = (AutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView2);
    autoCompleteTextView2.setAdapter(adapter2);
}

4. AutoComplete3#onCreate()

Project: codeexamples-android
File: AutoComplete3.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_3);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, AutoComplete1.COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
    textView = (AutoCompleteTextView) findViewById(R.id.edit2);
    textView.setAdapter(adapter);
}

5. AutoComplete3#onCreate()

Project: android-maven-plugin
File: AutoComplete3.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_3);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, AutoComplete1.COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
    textView = (AutoCompleteTextView) findViewById(R.id.edit2);
    textView.setAdapter(adapter);
}

6. AutoComplete5#onCreate()

Project: android-maven-plugin
File: AutoComplete5.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_5);
    ContentResolver content = getContentResolver();
    Cursor cursor = content.query(Contacts.CONTENT_URI, AutoComplete4.CONTACT_PROJECTION, null, null, null);
    AutoComplete4.ContactListAdapter adapter = new AutoComplete4.ContactListAdapter(this, cursor);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

7. AutoComplete4#onCreate()

Project: android-maven-plugin
File: AutoComplete4.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_4);
    ContentResolver content = getContentResolver();
    Cursor cursor = content.query(Contacts.CONTENT_URI, CONTACT_PROJECTION, null, null, null);
    ContactListAdapter adapter = new ContactListAdapter(this, cursor);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

8. AutoComplete2#onCreate()

Project: android-maven-plugin
File: AutoComplete2.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_2);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, AutoComplete1.COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

9. AutoComplete5#onCreate()

Project: codeexamples-android
File: AutoComplete5.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_5);
    ContentResolver content = getContentResolver();
    Cursor cursor = content.query(Contacts.CONTENT_URI, AutoComplete4.CONTACT_PROJECTION, null, null, null);
    AutoComplete4.ContactListAdapter adapter = new AutoComplete4.ContactListAdapter(this, cursor);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

10. AutoComplete4#onCreate()

Project: codeexamples-android
File: AutoComplete4.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_4);
    ContentResolver content = getContentResolver();
    Cursor cursor = content.query(Contacts.CONTENT_URI, CONTACT_PROJECTION, null, null, null);
    ContactListAdapter adapter = new ContactListAdapter(this, cursor);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

11. AutoComplete2#onCreate()

Project: codeexamples-android
File: AutoComplete2.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_2);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, AutoComplete1.COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

12. EditForumPostActivity#resetView()

Project: BotLibre
File: EditForumPostActivity.java
public void resetView() {
    HttpAction action = new HttpGetTagsAction(this, "Post");
    action.execute();
    ForumPostConfig instance = MainActivity.post;
    final AutoCompleteTextView tagsText = (AutoCompleteTextView) findViewById(R.id.tagsText);
    tagsText.setText(instance.tags);
    EditText text = (EditText) findViewById(R.id.topicText);
    text.setText(instance.topic);
    text = (EditText) findViewById(R.id.detailsText);
    text.setText(instance.details);
    CheckBox checkbox = (CheckBox) findViewById(R.id.featuredCheckBox);
    checkbox.setChecked(instance.isFeatured);
    if (!MainActivity.instance.isAdmin) {
        findViewById(R.id.featuredCheckBox).setVisibility(View.GONE);
    }
}

13. BrowsePostsActivity#browse()

Project: BotLibre
File: BrowsePostsActivity.java
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();
    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 = getType();
    if (MainActivity.instance != null) {
        config.instance = MainActivity.instance.id;
    }
    HttpAction action = new HttpGetPostsAction(this, config);
    action.execute();
}

14. BookEditLoaned#loanTo()

Project: Book-Catalogue
File: BookEditLoaned.java
/**
	 * Display the loan to page. It is slightly different to the existing loan page
	 */
private void loanTo() {
    ScrollView sv = (ScrollView) getView().findViewById(R.id.root);
    sv.removeAllViews();
    LayoutInflater inf = getActivity().getLayoutInflater();
    inf.inflate(R.layout.edit_book_loan, sv);
    AutoCompleteTextView mUserText = (AutoCompleteTextView) sv.findViewById(R.id.loan_to_who);
    try {
        ArrayAdapter<String> series_adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, getFriends());
        mUserText.setAdapter(series_adapter);
    } catch (Exception e) {
        Logger.logError(e);
    }
    Button mConfirmButton = (Button) sv.findViewById(R.id.confirm);
    mConfirmButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            String friend = saveLoan();
            loaned(friend);
        }
    });
}

15. FloatingLabelAutoCompleteTextView#afterLayoutInflated()

Project: android-floatinglabel-widgets
File: FloatingLabelAutoCompleteTextView.java
// =============================================================================================
// Overridden methods
// ==
@Override
protected void afterLayoutInflated(Context context, AttributeSet attrs, int defStyle) {
    super.afterLayoutInflated(context, attrs, defStyle);
    final CharSequence completionHint;
    final int completionThreshold;
    final int popupBackground;
    final int dropDownWidth;
    final int dropDownHeight;
    if (attrs == null) {
        completionHint = "";
        completionThreshold = 1;
        dropDownHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
        dropDownWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
        popupBackground = getDefaultPopupBackgroundResId();
    } else {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingLabelAutoCompleteTextView, defStyle, 0);
        completionHint = a.getText(R.styleable.FloatingLabelAutoCompleteTextView_android_completionHint);
        completionThreshold = a.getInt(R.styleable.FloatingLabelAutoCompleteTextView_android_completionThreshold, 1);
        dropDownHeight = a.getDimensionPixelSize(R.styleable.FloatingLabelAutoCompleteTextView_android_dropDownHeight, ViewGroup.LayoutParams.WRAP_CONTENT);
        dropDownWidth = a.getDimensionPixelSize(R.styleable.FloatingLabelAutoCompleteTextView_android_dropDownWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
        popupBackground = a.getResourceId(R.styleable.FloatingLabelAutoCompleteTextView_android_popupBackground, getDefaultPopupBackgroundResId());
        a.recycle();
    }
    final AutoCompleteTextView inputWidget = getInputWidget();
    inputWidget.setCompletionHint(completionHint);
    inputWidget.setThreshold(completionThreshold);
    inputWidget.setDropDownWidth(dropDownWidth);
    inputWidget.setDropDownHeight(dropDownHeight);
    inputWidget.setDropDownBackgroundResource(popupBackground);
    inputWidget.addTextChangedListener(new EditTextWatcher());
}

16. BoardEditController#showAddBoardDialog()

Project: Clover
File: BoardEditController.java
private void showAddBoardDialog() {
    LinearLayout wrap = new LinearLayout(context);
    wrap.setPadding(dp(16), dp(16), dp(16), 0);
    final AutoCompleteTextView text = new AutoCompleteTextView(context);
    text.setSingleLine();
    wrap.addView(text, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    FillAdapter fillAdapter = new FillAdapter(context, 0);
    fillAdapter.setEditingList(boards);
    fillAdapter.setAutoCompleteView(text);
    text.setAdapter(fillAdapter);
    text.setThreshold(1);
    text.setDropDownHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    text.setHint(R.string.board_add_hint);
    text.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
    AlertDialog dialog = new AlertDialog.Builder(context).setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface d, int which) {
            String value = text.getText().toString();
            if (!TextUtils.isEmpty(value)) {
                addBoard(value.toLowerCase(Locale.ENGLISH));
            }
        }
    }).setNegativeButton(R.string.cancel, null).setTitle(R.string.board_add).setView(wrap).create();
    AndroidUtils.requestKeyboardFocus(dialog, text);
    dialog.show();
}

17. EditDirectMessageActivity#initComponents()

Project: YiBo
File: EditDirectMessageActivity.java
private void initComponents() {
    LinearLayout llHeaderBase = (LinearLayout) findViewById(R.id.llHeaderBase);
    LinearLayout llContentPanel = (LinearLayout) findViewById(R.id.llContentPanel);
    AutoCompleteTextView etDisplayName = (AutoCompleteTextView) this.findViewById(R.id.etDisplayName);
    Button btnUserSelector = (Button) this.findViewById(R.id.btnUserSelector);
    LinearLayout llEditText = (LinearLayout) findViewById(R.id.llEditText);
    MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView) findViewById(R.id.etText);
    Button btnEmotion = (Button) this.findViewById(R.id.btnEmotion);
    Button btnMention = (Button) this.findViewById(R.id.btnMention);
    Button btnTopic = (Button) this.findViewById(R.id.btnTopic);
    Button btnTextCount = (Button) this.findViewById(R.id.btnTextCount);
    ThemeUtil.setSecondaryHeader(llHeaderBase);
    ThemeUtil.setContentBackground(llContentPanel);
    int padding6 = theme.dip2px(6);
    int padding8 = theme.dip2px(8);
    llContentPanel.setPadding(padding6, padding8, padding6, 0);
    etDisplayName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
    etDisplayName.setTextColor(theme.getColor("content"));
    btnUserSelector.setBackgroundDrawable(theme.getDrawable("selector_btn_message_user"));
    llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal"));
    etText.setTextColor(theme.getColor("content"));
    btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion"));
    btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention"));
    btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic"));
    btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count"));
    btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0);
    btnTextCount.setTextColor(theme.getColor("status_capability"));
    TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
    tvTitle.setText(R.string.title_edit_direct_message);
    if (StringUtil.isNotEmpty(displayName)) {
        etDisplayName.setText(displayName);
        etText.requestFocus();
    }
    etDisplayName.setAdapter(new UserSuggestAdapter(this));
    etDisplayName.setOnTouchListener(hideEmotionGridListener);
    int length = StringUtil.getLengthByByte(etText.getText().toString());
    int leavings = (int) Math.floor((double) (Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2);
    btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings));
    emotionViewController = new EmotionViewController(this);
}

18. EditWebMediumActivity#resetView()

Project: BotLibre
File: EditWebMediumActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void resetView() {
    HttpAction action = new HttpGetTagsAction(this, getType());
    action.execute();
    action = new HttpGetCategoriesAction(this, getType());
    action.execute();
    setTitle("Edit: " + MainActivity.instance.name);
    WebMediumConfig instance = (WebMediumConfig) MainActivity.instance;
    EditText text = (EditText) findViewById(R.id.descriptionText);
    text.setText(instance.description);
    text = (EditText) findViewById(R.id.detailsText);
    text.setText(instance.details);
    text = (EditText) findViewById(R.id.disclaimerText);
    text.setText(instance.disclaimer);
    CheckBox checkbox = (CheckBox) findViewById(R.id.privateCheckBox);
    checkbox.setChecked(instance.isPrivate);
    checkbox = (CheckBox) findViewById(R.id.hiddenCheckBox);
    checkbox.setChecked(instance.isHidden);
    final AutoCompleteTextView tagsText = (AutoCompleteTextView) findViewById(R.id.tagsText);
    tagsText.setText(instance.tags);
    tagsText.setThreshold(0);
    tagsText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            tagsText.showDropDown();
            return false;
        }
    });
    final AutoCompleteTextView categoriesText = (AutoCompleteTextView) findViewById(R.id.categoriesText);
    if (categoriesText != null) {
        categoriesText.setText(instance.categories);
        categoriesText.setThreshold(0);
        categoriesText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                categoriesText.showDropDown();
                return false;
            }
        });
    }
    Spinner accessModeSpin = (Spinner) findViewById(R.id.accessModeSpin);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, MainActivity.accessModes);
    accessModeSpin.setAdapter(adapter);
    accessModeSpin.setSelection(Arrays.asList(MainActivity.accessModes).indexOf(instance.accessMode));
}

19. EditWebMediumActivity#resetView()

Project: BotLibre
File: EditWebMediumActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void resetView() {
    HttpAction action = new HttpGetTagsAction(this, getType());
    action.execute();
    action = new HttpGetCategoriesAction(this, getType());
    action.execute();
    setTitle("Edit: " + MainActivity.instance.name);
    WebMediumConfig instance = (WebMediumConfig) MainActivity.instance;
    EditText text = (EditText) findViewById(R.id.descriptionText);
    text.setText(instance.description);
    text = (EditText) findViewById(R.id.detailsText);
    text.setText(instance.details);
    text = (EditText) findViewById(R.id.disclaimerText);
    text.setText(instance.disclaimer);
    CheckBox checkbox = (CheckBox) findViewById(R.id.privateCheckBox);
    checkbox.setChecked(instance.isPrivate);
    checkbox = (CheckBox) findViewById(R.id.hiddenCheckBox);
    checkbox.setChecked(instance.isHidden);
    final AutoCompleteTextView tagsText = (AutoCompleteTextView) findViewById(R.id.tagsText);
    tagsText.setText(instance.tags);
    tagsText.setThreshold(0);
    tagsText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            tagsText.showDropDown();
            return false;
        }
    });
    final AutoCompleteTextView categoriesText = (AutoCompleteTextView) findViewById(R.id.categoriesText);
    if (categoriesText != null) {
        categoriesText.setText(instance.categories);
        categoriesText.setThreshold(0);
        categoriesText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                categoriesText.showDropDown();
                return false;
            }
        });
    }
    Spinner accessModeSpin = (Spinner) findViewById(R.id.accessModeSpin);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, MainActivity.accessModes);
    accessModeSpin.setAdapter(adapter);
    accessModeSpin.setSelection(Arrays.asList(MainActivity.accessModes).indexOf(instance.accessMode));
}

20. CreateWebMediumActivity#resetView()

Project: BotLibre
File: CreateWebMediumActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void resetView() {
    final AutoCompleteTextView licenseText = (AutoCompleteTextView) findViewById(R.id.licenseText);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, new String[] { "Copyright " + MainActivity.user.user + " all rights reserved", "Public Domain", "Creative Commons Attribution 3.0 Unported License", "GNU General Public License 3.0", "Apache License, Version 2.0", "Eclipse Public License 1.0" });
    licenseText.setThreshold(0);
    licenseText.setAdapter(adapter);
    licenseText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            licenseText.showDropDown();
            return false;
        }
    });
    HttpAction action = new HttpGetTagsAction(this, getType());
    action.execute();
    action = new HttpGetCategoriesAction(this, getType());
    action.execute();
    Spinner accessModeSpin = (Spinner) findViewById(R.id.accessModeSpin);
    adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, MainActivity.accessModes);
    accessModeSpin.setAdapter(adapter);
}

21. CreateWebMediumActivity#resetView()

Project: BotLibre
File: CreateWebMediumActivity.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void resetView() {
    final AutoCompleteTextView licenseText = (AutoCompleteTextView) findViewById(R.id.licenseText);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.select_dialog_item, new String[] { "Copyright " + MainActivity.user.user + " all rights reserved", "Public Domain", "Creative Commons Attribution 3.0 Unported License", "GNU General Public License 3.0", "Apache License, Version 2.0", "Eclipse Public License 1.0" });
    licenseText.setThreshold(0);
    licenseText.setAdapter(adapter);
    licenseText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            licenseText.showDropDown();
            return false;
        }
    });
    HttpAction action = new HttpGetTagsAction(this, getType());
    action.execute();
    action = new HttpGetCategoriesAction(this, getType());
    action.execute();
    Spinner accessModeSpin = (Spinner) findViewById(R.id.accessModeSpin);
    adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, MainActivity.accessModes);
    accessModeSpin.setAdapter(adapter);
}

22. TagsControlSet#addTag()

Project: astrid
File: TagsControlSet.java
/** Adds a tag to the tag field */
boolean addTag(String tagName, boolean reuse) {
    LayoutInflater inflater = activity.getLayoutInflater();
    // check if already exists
    TextView lastText = null;
    for (int i = 0; i < newTags.getChildCount(); i++) {
        View view = newTags.getChildAt(i);
        lastText = (TextView) view.findViewById(R.id.text1);
        if (lastText.getText().equals(tagName))
            return false;
    }
    final View tagItem;
    if (reuse && lastText != null && lastText.getText().length() == 0) {
        tagItem = (View) lastText.getParent();
    } else {
        tagItem = inflater.inflate(R.layout.tag_edit_row, null);
        newTags.addView(tagItem);
    }
    if (tagName == null)
        //$NON-NLS-1$
        tagName = "";
    final AutoCompleteTextView textView = (AutoCompleteTextView) tagItem.findViewById(R.id.text1);
    textView.setText(tagName);
    textView.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
        //
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        //
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (count > 0 && newTags.getChildAt(newTags.getChildCount() - 1) == tagItem)
                //$NON-NLS-1$
                addTag("", false);
        }
    });
    textView.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
            if (actionId != EditorInfo.IME_NULL)
                return false;
            if (getLastTextView().getText().length() != 0) {
                //$NON-NLS-1$
                addTag("", false);
            }
            return true;
        }
    });
    ImageButton reminderRemoveButton;
    reminderRemoveButton = (ImageButton) tagItem.findViewById(R.id.button1);
    reminderRemoveButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            TextView lastView = getLastTextView();
            if (lastView == textView && textView.getText().length() == 0)
                return;
            if (newTags.getChildCount() > 1)
                newTags.removeView(tagItem);
            else
                //$NON-NLS-1$
                textView.setText("");
        }
    });
    return true;
}

23. DMSelectUserActivity#onCreate()

Project: weiciyuan
File: DMSelectUserActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dmselectuseractivity_layout);
    getActionBar().setTitle(R.string.select_dm_receiver);
    getActionBar().setDisplayShowHomeEnabled(false);
    getActionBar().setDisplayShowTitleEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    View title = getLayoutInflater().inflate(R.layout.dmselectuseractivity_title_layout, null);
    suggestProgressBar = (ProgressBar) title.findViewById(R.id.have_suggest_progressbar);
    getActionBar().setCustomView(title, new ActionBar.LayoutParams(Gravity.RIGHT));
    getActionBar().setDisplayShowCustomEnabled(true);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().replace(R.id.list_content, SelectFriendsListFragment.newInstance(GlobalContext.getInstance().getAccountBean().getInfo())).commit();
    }
    AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.search);
    AutoCompleteAdapter adapter = new AutoCompleteAdapter(this, android.R.layout.simple_dropdown_item_1line);
    search.setAdapter(adapter);
    search.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent();
            intent.putExtra("user", data.get(position));
            setResult(0, intent);
            finish();
        }
    });
}

24. FoodActivity#autoCompletefromAllFood()

Project: QiLi
File: FoodActivity.java
private void autoCompletefromAllFood() {
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(FoodActivity.this, android.R.layout.simple_list_item_1, allFood);
    AutoCompleteTextView autoText = (AutoCompleteTextView) findViewById(R.id.input_food_name);
    autoText.setAdapter(adapter);
    autoText.setThreshold(1);
}

25. AutoCompleteActivity#onCreate()

Project: coursera-android
File: AutoCompleteActivity.java
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Get a reference to the AutoCompleteTextView
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
    // Create an ArrayAdapter containing country names
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
    // Set the adapter for the AutoCompleteTextView
    textView.setAdapter(adapter);
    textView.setOnItemClickListener(new OnItemClickListener() {

        // Display a Toast Message when the user clicks on an item in the AutoCompleteTextView
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Toast.makeText(getApplicationContext(), "The winner is:" + arg0.getAdapter().getItem(arg2), Toast.LENGTH_SHORT).show();
        }
    });
}

26. StartConversationActivity#showJoinConferenceDialog()

Project: Conversations
File: StartConversationActivity.java
@SuppressLint("InflateParams")
protected void showJoinConferenceDialog(final String prefilledJid) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.join_conference);
    final View dialogView = getLayoutInflater().inflate(R.layout.join_conference_dialog, null);
    final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
    final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
    final TextView jabberIdDesc = (TextView) dialogView.findViewById(R.id.jabber_id);
    jabberIdDesc.setText(R.string.conference_address);
    jid.setHint(R.string.conference_address_example);
    jid.setAdapter(new KnownHostsAdapter(this, R.layout.simple_list_item, mKnownConferenceHosts));
    if (prefilledJid != null) {
        jid.append(prefilledJid);
    }
    populateAccountSpinner(this, mActivatedAccounts, spinner);
    final Checkable bookmarkCheckBox = (CheckBox) dialogView.findViewById(R.id.bookmark);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.join, null);
    final AlertDialog dialog = builder.create();
    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            if (!xmppConnectionServiceBound) {
                return;
            }
            final Account account = getSelectedAccount(spinner);
            if (account == null) {
                return;
            }
            final Jid conferenceJid;
            try {
                conferenceJid = Jid.fromString(jid.getText().toString());
            } catch (final InvalidJidException e) {
                jid.setError(getString(R.string.invalid_jid));
                return;
            }
            if (bookmarkCheckBox.isChecked()) {
                if (account.hasBookmarkFor(conferenceJid)) {
                    jid.setError(getString(R.string.bookmark_already_exists));
                } else {
                    final Bookmark bookmark = new Bookmark(account, conferenceJid.toBareJid());
                    bookmark.setAutojoin(getPreferences().getBoolean("autojoin", true));
                    String nick = conferenceJid.getResourcepart();
                    if (nick != null && !nick.isEmpty()) {
                        bookmark.setNick(nick);
                    }
                    account.getBookmarks().add(bookmark);
                    xmppConnectionService.pushBookmarks(account);
                    final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, conferenceJid, true);
                    conversation.setBookmark(bookmark);
                    if (!conversation.getMucOptions().online()) {
                        xmppConnectionService.joinMuc(conversation);
                    }
                    dialog.dismiss();
                    switchToConversation(conversation);
                }
            } else {
                final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, conferenceJid, true);
                if (!conversation.getMucOptions().online()) {
                    xmppConnectionService.joinMuc(conversation);
                }
                dialog.dismiss();
                switchToConversation(conversation);
            }
        }
    });
}

27. EditSeriesList#editSeries()

Project: Book-Catalogue
File: EditSeriesList.java
private void editSeries(final Series series) {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.edit_book_series);
    dialog.setTitle(R.string.edit_book_series);
    AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
    seriesView.setText(series.name);
    seriesView.setAdapter(mSeriesAdapter);
    EditText numView = (EditText) dialog.findViewById(R.id.series_num);
    numView.setText(series.num);
    setTextOrHideView(dialog.findViewById(R.id.title_label), mBookTitleLabel);
    setTextOrHideView(dialog.findViewById(R.id.title), mBookTitle);
    Button saveButton = (Button) dialog.findViewById(R.id.confirm);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
            EditText numView = (EditText) dialog.findViewById(R.id.series_num);
            String newName = seriesView.getText().toString().trim();
            if (newName == null || newName.length() == 0) {
                Toast.makeText(EditSeriesList.this, R.string.series_is_blank, Toast.LENGTH_LONG).show();
                return;
            }
            Series newSeries = new Series(newName, numView.getText().toString());
            confirmEditSeries(series, newSeries);
            dialog.dismiss();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

28. SearchViewHacker#setHint()

Project: actor-platform
File: SearchViewHacker.java
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);
}

29. LoginDialogFragment#prepareInputBoxes()

Project: openshop.io-android
File: LoginDialogFragment.java
private void prepareInputBoxes(View view) {
    // Registration form
    loginRegistrationEmailWrapper = (TextInputLayout) view.findViewById(R.id.login_registration_email_wrapper);
    loginRegistrationPasswordWrapper = (TextInputLayout) view.findViewById(R.id.login_registration_password_wrapper);
    loginRegistrationGenderWoman = (RadioButton) view.findViewById(R.id.login_registration_sex_woman);
    EditText registrationPassword = loginRegistrationPasswordWrapper.getEditText();
    if (registrationPassword != null) {
        registrationPassword.setOnTouchListener(new OnTouchPasswordListener(registrationPassword));
    }
    // Login email form
    loginEmailEmailWrapper = (TextInputLayout) view.findViewById(R.id.login_email_email_wrapper);
    EditText loginEmail = loginEmailEmailWrapper.getEditText();
    if (loginEmail != null)
        loginEmail.setText(SettingsMy.getUserEmailHint());
    loginEmailPasswordWrapper = (TextInputLayout) view.findViewById(R.id.login_email_password_wrapper);
    EditText emailPassword = loginEmailPasswordWrapper.getEditText();
    if (emailPassword != null) {
        emailPassword.setOnTouchListener(new OnTouchPasswordListener(emailPassword));
        emailPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEND || actionId == 124) {
                    invokeLoginWithEmail();
                    return true;
                }
                return false;
            }
        });
    }
    loginEmailForgottenEmailWrapper = (TextInputLayout) view.findViewById(R.id.login_email_forgotten_email_wrapper);
    EditText emailForgottenPassword = loginEmailForgottenEmailWrapper.getEditText();
    if (emailForgottenPassword != null)
        emailForgottenPassword.setText(SettingsMy.getUserEmailHint());
    // Simple accounts whisperer.
    Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
    String[] addresses = new String[accounts.length];
    for (int i = 0; i < accounts.length; i++) {
        addresses[i] = accounts[i].name;
        Timber.e("Sets autocompleteEmails: %s", accounts[i].name);
    }
    ArrayAdapter<String> emails = new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, addresses);
    AutoCompleteTextView textView = (AutoCompleteTextView) view.findViewById(R.id.login_registration_email_text_auto);
    textView.setAdapter(emails);
}

30. SendActivity#onCreate()

Project: double-espresso
File: SendActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.send_activity);
    EditText editText = (EditText) findViewById(R.id.enter_data_edit_text);
    editText.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                EditText editText = (EditText) view;
                TextView responseText = (TextView) findViewById(R.id.enter_data_response_text);
                responseText.setText(editText.getText());
                return true;
            } else {
                return false;
            }
        }
    });
    final EditText searchBox = (EditText) findViewById(R.id.search_box);
    searchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                TextView result = (TextView) findViewById(R.id.search_result);
                result.setText(getString(R.string.searching_for_label) + " " + v.getText());
                result.setVisibility(View.VISIBLE);
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0);
                return true;
            }
            return false;
        }
    });
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view);
    String[] completions = new String[] { "Pacific Ocean", "Atlantic Ocean", "Indian Ocean", "Southern Ocean", "Artic Ocean", "Mediterranean Sea", "Caribbean Sea", "South China Sea", "Bering Sea", "Gulf of Mexico", "Okhotsk Sea", "East China Sea", "Hudson Bay", "Japan Sea", "Andaman Sea", "North Sea", "Red Sea", "Baltic Sea" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, completions);
    autoComplete.setAdapter(adapter);
}

31. SendActivity#onCreate()

Project: double-espresso
File: SendActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.send_activity);
    EditText editText = (EditText) findViewById(R.id.enter_data_edit_text);
    editText.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                EditText editText = (EditText) view;
                TextView responseText = (TextView) findViewById(R.id.enter_data_response_text);
                responseText.setText(editText.getText());
                return true;
            } else {
                return false;
            }
        }
    });
    final EditText searchBox = (EditText) findViewById(R.id.search_box);
    searchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                TextView result = (TextView) findViewById(R.id.search_result);
                result.setText(getString(R.string.searching_for_label) + " " + v.getText());
                result.setVisibility(View.VISIBLE);
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0);
                return true;
            }
            return false;
        }
    });
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view);
    String[] completions = new String[] { "Pacific Ocean", "Atlantic Ocean", "Indian Ocean", "Southern Ocean", "Artic Ocean", "Mediterranean Sea", "Caribbean Sea", "South China Sea", "Bering Sea", "Gulf of Mexico", "Okhotsk Sea", "East China Sea", "Hudson Bay", "Japan Sea", "Andaman Sea", "North Sea", "Red Sea", "Baltic Sea" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, completions);
    autoComplete.setAdapter(adapter);
}

32. SampleDialogFragment#onCreateDialog()

Project: cwac-security
File: SampleDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View form = getActivity().getLayoutInflater().inflate(R.layout.main, null);
    AutoCompleteTextView autocomplete = (AutoCompleteTextView) form.findViewById(R.id.autocomplete);
    autocomplete.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, MainActivity.ITEMS));
    Spinner spinner = (Spinner) form.findViewById(R.id.spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, MainActivity.ITEMS);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner = (Spinner) form.findViewById(R.id.spinner2);
    adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, MainActivity.ITEMS);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    Dialog dlg = builder.setTitle(R.string.activity_label).setView(form).setNegativeButton(android.R.string.cancel, null).create();
    if (MainActivity.fixFlagSecure()) {
        dlg = FlagSecureHelper.markDialogAsSecure(dlg);
    }
    return (dlg);
}

33. MainActivity#onCreate()

Project: cwac-security
File: MainActivity.java
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (BuildConfig.USE_FLAG_SECURE) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    }
    setContentView(R.layout.main);
    popupAnchor = findViewById(R.id.popup_anchor);
    AutoCompleteTextView autocomplete = (AutoCompleteTextView) findViewById(R.id.autocomplete);
    autocomplete.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, ITEMS));
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ITEMS);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner = (Spinner) findViewById(R.id.spinner2);
    adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ITEMS);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    final View contextMenu = findViewById(R.id.context_menu);
    registerForContextMenu(contextMenu);
    contextMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openContextMenu(contextMenu);
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Toolbar tb = (Toolbar) findViewById(R.id.toolbar);
        tb.setTitle("Toolbar");
        tb.inflateMenu(R.menu.common);
        tb.setOnMenuItemClickListener(new OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return (onOptionsItemSelected(item));
            }
        });
    }
}

34. AutoCompleteDemo#onCreate()

Project: codeexamples-android
File: AutoCompleteDemo.java
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    AutoCompleteTextView view = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
    String[] values = new String[] { "Linux", "Ubuntu", "iPhone", "Android" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, values);
    view.setAdapter(adapter);
}

35. AutoComplete1#onCreate()

Project: codeexamples-android
File: AutoComplete1.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_1);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

36. BrowseActivity#browse()

Project: BotLibre
File: BrowseActivity.java
public void browse(View view) {
    BrowseConfig config = new BrowseConfig();
    config.typeFilter = "Public";
    RadioButton radio = (RadioButton) findViewById(R.id.privateRadio);
    if (radio.isChecked()) {
        config.typeFilter = "Private";
    }
    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 = getType();
    HttpAction action = new HttpGetInstancesAction(this, config);
    action.execute();
}

37. BrowseActivity#browse()

Project: BotLibre
File: BrowseActivity.java
public void browse(View view) {
    BrowseConfig config = new BrowseConfig();
    config.typeFilter = "Public";
    RadioButton radio = (RadioButton) findViewById(R.id.privateRadio);
    if (radio.isChecked()) {
        config.typeFilter = "Private";
    }
    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 = getType();
    HttpAction action = new HttpGetInstancesAction(this, config);
    action.execute();
}

38. EditSeriesDialog#editSeries()

Project: Book-Catalogue
File: EditSeriesDialog.java
public void editSeries(final Series series) {
    final Dialog dialog = new Dialog(mContext);
    dialog.setContentView(R.layout.edit_series);
    dialog.setTitle(R.string.edit_series);
    AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
    try {
        seriesView.setText(series.name);
    } catch (NullPointerException e) {
        Logger.logError(e);
    }
    seriesView.setAdapter(mSeriesAdapter);
    Button saveButton = (Button) dialog.findViewById(R.id.confirm);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AutoCompleteTextView seriesView = (AutoCompleteTextView) dialog.findViewById(R.id.series);
            String newName = seriesView.getText().toString().trim();
            if (newName == null || newName.length() == 0) {
                Toast.makeText(mContext, R.string.series_is_blank, Toast.LENGTH_LONG).show();
                return;
            }
            Series newSeries = new Series(newName, "");
            confirmEditSeries(series, newSeries);
            dialog.dismiss();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

39. EditFormatDialog#edit()

Project: Book-Catalogue
File: EditFormatDialog.java
public void edit(final String origFormat) {
    final Dialog dialog = new Dialog(mContext);
    dialog.setContentView(R.layout.edit_format);
    dialog.setTitle(R.string.edit_format_name);
    AutoCompleteTextView nameView = (AutoCompleteTextView) dialog.findViewById(R.id.name);
    try {
        nameView.setText(origFormat);
    } catch (NullPointerException e) {
        Logger.logError(e);
    }
    nameView.setAdapter(mAdapter);
    Button saveButton = (Button) dialog.findViewById(R.id.confirm);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AutoCompleteTextView nameView = (AutoCompleteTextView) dialog.findViewById(R.id.name);
            String newName = nameView.getText().toString().trim();
            if (newName == null || newName.length() == 0) {
                Toast.makeText(mContext, R.string.name_can_not_be_blank, Toast.LENGTH_LONG).show();
                return;
            }
            confirmEditFormat(origFormat, newName);
            dialog.dismiss();
        }
    });
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

40. SuggestActivity#setUpAutoCompleteTextView()

Project: android-testing
File: SuggestActivity.java
/**
     * Creates an adapter and sets it to an {@link AutoCompleteTextView} to enable suggestions.
     */
private void setUpAutoCompleteTextView() {
    String[] completions = getResources().getStringArray(R.array.bodies_of_water);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, completions);
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view);
    autoComplete.setAdapter(adapter);
}

41. AutoComplete1#onCreate()

Project: android-maven-plugin
File: AutoComplete1.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.autocomplete_1);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
}

42. CollapsibleMenuUtils#addSearchMenuItem()

Project: Android-CollapsibleSearchMenu
File: CollapsibleMenuUtils.java
/**
	 * Adding collapsible search menu item to the menu.
	 * @param menu
	 * @param isLightTheme - true if use light them for ActionBar, else false
	 * @return
	 */
public static MenuItem addSearchMenuItem(Menu menu, boolean isLightTheme, final TextWatcher textWatcher) {
    final MenuItem menuItem = menu.add(Menu.NONE, R.id.collapsible_search_menu_item, Menu.NONE, R.string.search_go);
    menuItem.setIcon(isLightTheme ? R.drawable.ic_action_search_holo_light : R.drawable.ic_action_search_holo_dark).setActionView(isLightTheme ? R.layout.search_view_holo_light : R.layout.search_view_holo_dark).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    final View searchView = menuItem.getActionView();
    final AutoCompleteTextView editText = (AutoCompleteTextView) searchView.findViewById(R.id.search_src_text);
    menuItem.setOnActionExpandListener(new OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            editText.addTextChangedListener(textWatcher);
            editText.requestFocus();
            showKeyboard(editText);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            editText.setText(null);
            editText.removeTextChangedListener(textWatcher);
            // editText.clearFocus();
            hideKeyboard(editText);
            return true;
        }
    });
    final View searchPlate = searchView.findViewById(R.id.search_plate);
    editText.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, final boolean hasFocus) {
            searchView.post(new Runnable() {

                public void run() {
                    searchPlate.getBackground().setState(hasFocus ? new int[] { android.R.attr.state_focused } : new int[] { android.R.attr.state_empty });
                    searchView.invalidate();
                }
            });
        }
    });
    final ImageView closeBtn = (ImageView) menuItem.getActionView().findViewById(R.id.search_close_btn);
    closeBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!TextUtils.isEmpty(editText.getText())) {
                editText.setText(null);
            } else {
                menuItem.collapseActionView();
            }
        }
    });
    return menuItem;
}

43. CollapsibleMenuUtils#addSearchMenuItem()

Project: Android-CollapsibleSearchMenu
File: CollapsibleMenuUtils.java
/**
     * Adding collapsible search menu item to the menu.
     *
     * @param menu
     * @param isLightTheme - true if use light them for ActionBar, else false
     * @return menu item
     */
public static MenuItem addSearchMenuItem(Menu menu, boolean isLightTheme, final OnQueryTextListener onQueryChangeListener) {
    final MenuItem menuItem = menu.add(Menu.NONE, R.id.collapsible_search_menu_item, Menu.NONE, R.string.search_go);
    menuItem.setIcon(isLightTheme ? R.drawable.ic_action_search_holo_light : R.drawable.ic_action_search_holo_dark).setActionView(isLightTheme ? R.layout.search_view_holo_light : R.layout.search_view_holo_dark).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    final View searchView = menuItem.getActionView();
    final AutoCompleteTextView editText = (AutoCompleteTextView) searchView.findViewById(R.id.search_src_text);
    final TextWatcher textWatcher = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            onQueryChangeListener.onQueryTextChange(charSequence.toString());
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    };
    final TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_SEARCH || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                onQueryChangeListener.onQueryTextSubmit(textView.getText().toString());
                return true;
            }
            return false;
        }
    };
    menuItem.setOnActionExpandListener(new OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            editText.addTextChangedListener(textWatcher);
            editText.setOnEditorActionListener(onEditorActionListener);
            editText.requestFocus();
            showKeyboard(editText);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            editText.setText(null);
            editText.removeTextChangedListener(textWatcher);
            // editText.clearFocus();
            hideKeyboard(editText);
            return true;
        }
    });
    final View searchPlate = searchView.findViewById(R.id.search_plate);
    editText.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, final boolean hasFocus) {
            searchView.post(new Runnable() {

                public void run() {
                    searchPlate.getBackground().setState(hasFocus ? new int[] { android.R.attr.state_focused } : new int[] { android.R.attr.state_empty });
                    searchView.invalidate();
                }
            });
        }
    });
    final ImageView closeBtn = (ImageView) menuItem.getActionView().findViewById(R.id.search_close_btn);
    closeBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!TextUtils.isEmpty(editText.getText())) {
                editText.setText(null);
            } else {
                menuItem.collapseActionView();
            }
        }
    });
    return menuItem;
}

44. SearchViewHacker#setText()

Project: actor-platform
File: SearchViewHacker.java
public static void setText(SearchView searchView, int color) {
    AutoCompleteTextView autoComplete = (AutoCompleteTextView) findView(searchView, "mQueryTextView");
    autoComplete.setTextColor(color);
// autoComplete.setHighlightColor(color);
}

45. EditAuthorList#onSave()

Project: Book-Catalogue
File: EditAuthorList.java
@Override
protected boolean onSave(Intent intent) {
    final AutoCompleteTextView t = ((AutoCompleteTextView) EditAuthorList.this.findViewById(R.id.author));
    Resources res = this.getResources();
    String s = t.getText().toString().trim();
    if (s.length() > 0) {
        final AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage(res.getText(R.string.unsaved_edits)).create();
        alertDialog.setTitle(res.getText(R.string.unsaved_edits_title));
        alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, res.getText(R.string.yes), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                t.setText("");
                findViewById(R.id.confirm).performClick();
            }
        });
        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, res.getText(R.string.no), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
            //do nothing
            }
        });
        alertDialog.show();
        return false;
    } else {
        return true;
    }
}

46. EditAuthorList#onAdd()

Project: Book-Catalogue
File: EditAuthorList.java
/**
	 * Do the work of the onClickListener for the 'Add' button.
	 *
	 * @param v
	 */
protected void onAdd(View v) {
    // Get the text
    AutoCompleteTextView t = ((AutoCompleteTextView) EditAuthorList.this.findViewById(R.id.author));
    String s = t.getText().toString().trim();
    if (s.length() > 0) {
        // Get an author and try to find in DB.
        Author a = new Author(t.getText().toString());
        a.id = mDbHelper.lookupAuthorId(a);
        //
        boolean foundMatch = false;
        for (int i = 0; i < mList.size() && !foundMatch; i++) {
            if (a.id != 0L) {
                if (mList.get(i).id == a.id)
                    foundMatch = true;
            } else {
                if (a.getDisplayName().equals(mList.get(i).getDisplayName()))
                    foundMatch = true;
            }
        }
        if (foundMatch) {
            Toast.makeText(EditAuthorList.this, getResources().getString(R.string.author_already_in_list), Toast.LENGTH_LONG).show();
            return;
        }
        mList.add(a);
        mAdapter.notifyDataSetChanged();
        t.setText("");
    } else {
        Toast.makeText(EditAuthorList.this, getResources().getString(R.string.author_is_blank), Toast.LENGTH_LONG).show();
    }
}

47. BookEditLoaned#saveLoan()

Project: Book-Catalogue
File: BookEditLoaned.java
/**
	 * Save the user and book combination as a loan in the database
	 * 
	 * @return the user
	 */
private String saveLoan() {
    AutoCompleteTextView mUserText = (AutoCompleteTextView) getView().findViewById(R.id.loan_to_who);
    String friend = mUserText.getText().toString();
    BookData values = mEditManager.getBookData();
    values.putString(CatalogueDBAdapter.KEY_LOANED_TO, friend);
    mDbHelper.createLoan(values, true);
    return friend;
}

48. SearchViewStyle#setCursorColor()

Project: tomahawk-android
File: SearchViewStyle.java
public SearchViewStyle setCursorColor(final int color) {
    final AutoCompleteTextView editText = getView(android.support.v7.appcompat.R.id.search_src_text);
    if (editText != null) {
        try {
            final Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
            fCursorDrawableRes.setAccessible(true);
            final int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
            final Field fEditor = TextView.class.getDeclaredField("mEditor");
            fEditor.setAccessible(true);
            final Object editor = fEditor.get(editText);
            final Class<?> clazz = editor.getClass();
            final Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
            fCursorDrawable.setAccessible(true);
            final Drawable[] drawables = new Drawable[2];
            drawables[0] = editText.getContext().getResources().getDrawable(mCursorDrawableRes);
            drawables[1] = editText.getContext().getResources().getDrawable(mCursorDrawableRes);
            drawables[0].setColorFilter(color, PorterDuff.Mode.SRC_IN);
            drawables[1].setColorFilter(color, PorterDuff.Mode.SRC_IN);
            fCursorDrawable.set(editor, drawables);
        } catch (final Throwable ignored) {
        }
    }
    return this;
}

49. RxAutoCompleteTextViewTestActivity#onCreate()

Project: RxBinding
File: RxAutoCompleteTextViewTestActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    setContentView(layout);
    autoCompleteTextView = new AutoCompleteTextView(this);
    autoCompleteTextView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    autoCompleteTextView.setId(R.id.auto_complete);
    layout.addView(autoCompleteTextView);
}

50. HttpGetTagsAction#onPostExecute()

Project: BotLibre
File: HttpGetTagsAction.java
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void onPostExecute(String xml) {
    if (this.exception != null) {
        return;
    }
    if (this.config.type.equals("Bot")) {
        MainActivity.tags = this.tags;
    } else if (this.config.type.equals("Forum")) {
        MainActivity.forumTags = this.tags;
    } else if (this.config.type.equals("Post")) {
        MainActivity.forumPostTags = this.tags;
    } else if (this.config.type.equals("Channel")) {
        MainActivity.channelTags = this.tags;
    }
    final AutoCompleteTextView tagsText = (AutoCompleteTextView) this.activity.findViewById(R.id.tagsText);
    if (tagsText != null) {
        ArrayAdapter adapter = new ArrayAdapter(this.activity, android.R.layout.select_dialog_item, this.tags);
        tagsText.setThreshold(0);
        tagsText.setAdapter(adapter);
        tagsText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                tagsText.showDropDown();
                return false;
            }
        });
    }
}

51. HttpGetCategoriesAction#onPostExecute()

Project: BotLibre
File: HttpGetCategoriesAction.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onPostExecute(String xml) {
    if (this.exception != null) {
        return;
    }
    if (this.config.type.equals("Bot")) {
        MainActivity.categories = this.categories;
    } else if (this.config.type.equals("Forum")) {
        MainActivity.forumCategories = this.categories;
    } else if (this.config.type.equals("Channel")) {
        MainActivity.channelCategories = this.categories;
    }
    final AutoCompleteTextView categoriesText = (AutoCompleteTextView) this.activity.findViewById(R.id.categoriesText);
    if (categoriesText != null) {
        ArrayAdapter adapter = new ArrayAdapter(this.activity, android.R.layout.select_dialog_item, this.categories);
        categoriesText.setThreshold(0);
        categoriesText.setAdapter(adapter);
        categoriesText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                categoriesText.showDropDown();
                return false;
            }
        });
    }
}

52. HttpGetTagsAction#onPostExecute()

Project: BotLibre
File: HttpGetTagsAction.java
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void onPostExecute(String xml) {
    if (this.exception != null) {
        return;
    }
    if (this.config.type.equals("Bot")) {
        MainActivity.tags = this.tags;
    } else if (this.config.type.equals("Forum")) {
        MainActivity.forumTags = this.tags;
    } else if (this.config.type.equals("Post")) {
        MainActivity.forumPostTags = this.tags;
    } else if (this.config.type.equals("Channel")) {
        MainActivity.channelTags = this.tags;
    }
    final AutoCompleteTextView tagsText = (AutoCompleteTextView) this.activity.findViewById(R.id.tagsText);
    if (tagsText != null) {
        ArrayAdapter adapter = new ArrayAdapter(this.activity, android.R.layout.select_dialog_item, this.tags);
        tagsText.setThreshold(0);
        tagsText.setAdapter(adapter);
        tagsText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                tagsText.showDropDown();
                return false;
            }
        });
    }
}

53. HttpGetCategoriesAction#onPostExecute()

Project: BotLibre
File: HttpGetCategoriesAction.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onPostExecute(String xml) {
    if (this.exception != null) {
        return;
    }
    if (this.config.type.equals("Bot")) {
        MainActivity.categories = this.categories;
    } else if (this.config.type.equals("Forum")) {
        MainActivity.forumCategories = this.categories;
    } else if (this.config.type.equals("Channel")) {
        MainActivity.channelCategories = this.categories;
    }
    final AutoCompleteTextView categoriesText = (AutoCompleteTextView) this.activity.findViewById(R.id.categoriesText);
    if (categoriesText != null) {
        ArrayAdapter adapter = new ArrayAdapter(this.activity, android.R.layout.select_dialog_item, this.categories);
        categoriesText.setThreshold(0);
        categoriesText.setAdapter(adapter);
        categoriesText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                categoriesText.showDropDown();
                return false;
            }
        });
    }
}

54. EditSeriesList#onSave()

Project: Book-Catalogue
File: EditSeriesList.java
@Override
protected boolean onSave(Intent intent) {
    final AutoCompleteTextView t = ((AutoCompleteTextView) EditSeriesList.this.findViewById(R.id.series));
    Resources res = this.getResources();
    String s = t.getText().toString().trim();
    if (s.length() > 0) {
        final AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage(res.getText(R.string.unsaved_edits)).create();
        alertDialog.setTitle(res.getText(R.string.unsaved_edits_title));
        alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, res.getText(R.string.yes), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                t.setText("");
                findViewById(R.id.confirm).performClick();
            }
        });
        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, res.getText(R.string.no), new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
            //do nothing
            }
        });
        alertDialog.show();
        return false;
    } else {
        return true;
    }
}

55. EditSeriesList#onAdd()

Project: Book-Catalogue
File: EditSeriesList.java
@Override
protected void onAdd(View v) {
    AutoCompleteTextView t = ((AutoCompleteTextView) EditSeriesList.this.findViewById(R.id.series));
    String s = t.getText().toString().trim();
    if (s.length() > 0) {
        EditText et = ((EditText) EditSeriesList.this.findViewById(R.id.series_num));
        String n = et.getText().toString();
        if (n == null)
            n = "";
        Series series = new Series(t.getText().toString(), n);
        series.id = mDbHelper.lookupSeriesId(series);
        boolean foundMatch = false;
        try {
            for (int i = 0; i < mList.size() && !foundMatch; i++) {
                if (series.name.equals(mList.get(i).name) && series.num.equals(mList.get(i).num)) {
                    foundMatch = true;
                }
            }
        } catch (NullPointerException e) {
            Logger.logError(e, "while adding series");
        }
        if (foundMatch) {
            Toast.makeText(EditSeriesList.this, getResources().getString(R.string.series_already_in_list), Toast.LENGTH_LONG).show();
            return;
        }
        mList.add(series);
        mAdapter.notifyDataSetChanged();
        t.setText("");
        et.setText("");
    } else {
        Toast.makeText(EditSeriesList.this, getResources().getString(R.string.series_is_blank), Toast.LENGTH_LONG).show();
    }
}