Search code examples
androidautocompletetextview

Show AutoCompleteTextView Popup always above of TextField


I am trying to develop small app in which i used AutoCompleteTextView and i used

           simpleCursorAdapter.setFilterQueryProvider(new FilterQueryProvider() {
                      // my stub here
          }

As my filtration goes specific ,my Dropdown(Anchor) goes beneath of Virtual keyboard. That means supppose that first i search with DR. then it shows list of 15 doctor in Dropdown(Anchor) with no any problem. But as i typed DR.Kum , now Dropdown(Anchor) have only one name so that Dropdown(Anchor) goes down of virtual keyboard . When it has 15 name of list it showing perfectly.How to show Dropdown(Anchor) always above of AutoCompleteTextView.??


Solution

  • I solved this problem by one trick

           // It will capture number item in your DropDown . If number of item in drop is 2
          // or 1 , then hide keyboard.
          if(cur_hide_keyboard.getCount() ==2 || cur_hide_keyboard.getCount() ==1){
                                    hideKeyBoard();
                                }
    
             private void hideKeyBoard() {
            InputMethodManager imm = (InputMethodManager) activity
                    .getSystemService(Activity.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(doctorsName.getWindowToken(), 0);
        }