2016-12-08 2 views
4

J'ai un AppCompatAutoCompleteTextView au bas d'un DialogFragment.Clavier cache AutoCompleteTextView liste déroulante

Sur tablette (API 19) en mode paysage, la liste déroulante est couverte par le clavier lorsqu'il n'y a qu'un élément dans la liste des suggestions. Quand il y a plus d'éléments, la liste déroulante monte et fonctionne bien.

Sur mobile (API 22), il n'y a pas de problème même s'il n'y a qu'un seul élément dans la liste des suggestions, la liste déroulante est toujours affichée vers le haut. J'ai déjà ajouté android:windowSoftInputMode="adjustPan|stateHidden" à l'activité dans le manifeste.

Comment puis-je faire en sorte que la liste déroulante monte toujours ou ne soit pas couverte par le clavier?

Répondre

0
Work around the below the completionThreshold. Hope it works for you! 
<AutoCompleteTextView 
    android:id="@+id/someID" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:completionThreshold="1" /> 

ou

autocomplete.setThreshold(2); 
0
public static void hideSoftKeyboard(Activity activity) { 
    InputMethodManager inputMethodManager = 
      (InputMethodManager) activity.getSystemService(
        Activity.INPUT_METHOD_SERVICE); 
    inputMethodManager.hideSoftInputFromWindow(
      activity.getCurrentFocus().getWindowToken(), 0); 
} 

public void setupUI(View view) { 

    // Set up touch listener for non-text box views to hide keyboard. 
    if (!(view instanceof EditText)) { 
     view.setOnTouchListener(new View.OnTouchListener() { 
      public boolean onTouch(View v, MotionEvent event) { 
       hideSoftKeyboard(getActivity()); 
       return false; 
      } 
     }); 
    } 

    //If a layout container, iterate over children and seed recursion. 
    if (view instanceof ViewGroup) { 
     for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { 
      View innerView = ((ViewGroup) view).getChildAt(i); 
      setupUI(innerView); 
     } 
    } 
} 

Ajoutez cette ligne dans votre oncreatesetupUI(rootView.findViewById(R.id.parent));