mancj / MaterialSearchBar

Material Design Search Bar for Android
Other
2.03k stars 332 forks source link

drop down not appearing #120

Closed digitxo closed 5 years ago

digitxo commented 5 years ago
String[] friendList;
        List<String> stockList = new ArrayList<String>();
        for (Map.Entry<String, Object> entry : userList.entrySet()) {

            stockList.add(entry.getKey());

        }
        String[] stockArr = new String[stockList.size()];
        friendList = stockList.toArray(stockArr);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.select_dialog_singlechoice, friendList);
        //Find TextView control

        MaterialSearchBar searchBar = (MaterialSearchBar) findViewById(R.id.friendList);
        LayoutInflater Xinflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

        searchBar.setMaxSuggestionCount(10);
        searchBar.setHint("Find a friend..");

        CustomSuggestionsAdapter newAdapter = new CustomSuggestionsAdapter(Xinflater);
        newAdapter.setSuggestions(stockList);

        searchBar.setCustomSuggestionAdapter(newAdapter);

        searchBar.addTextChangeListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                Log.d("LOG_TAG", getClass().getSimpleName() + " text changed " + searchBar.getText());
                // send the entered text to our filter and let it manage everything
                newAdapter.getFilter().filter(searchBar.getText());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }

        });

Here is my code... the dropdown is NOT appearing. Pls help.