Listview only appears when I click to close the keyboard

Asked

Viewed 102 times

1

I do not know how to solve this problem, but the list-View does not appear when I do the search, it only comes when I click the button to close the keyboard, it seems that when I press the button it updates the Activity and then appears very strange.

Follow below images with the problem.

Att Cristiano.

List_View não aparece

O list-view só aparece quando clico no botão para fechar o teclado

Code

<RelativeLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/wallpaper"
    android:windowSoftInputMode="adjustPan">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:windowSoftInputMode="adjustPan">

        <TextView
            android:id="@+id/textView10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:text="O que você está procurando?"
            android:textColor="#fb7b03"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/edtBusca"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/textView10"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="48dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/editstyle"
            android:inputType="textCapSentences" />

        <ImageView
            android:id="@+id/imgprocurar"
            android:layout_width="40dp"
            android:layout_height="30dp"
            android:layout_alignParentEnd="true"
            android:layout_alignTop="@+id/edtBusca"
            android:layout_marginRight="10dp"
            android:background="#00ffffff"
            android:src="@drawable/procurar" />

        <Spinner
            android:id="@+id/spnOrdenar"
            android:layout_width="fill_parent"
            android:layout_height="35dp"
            android:layout_alignParentStart="true"
            android:layout_alignWithParentIfMissing="false"
            android:layout_below="@+id/textView11"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/editstyle"
            android:gravity="center" />

        <TextView
            android:id="@+id/textView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/edtBusca"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:text="Organizar por:"
            android:textColor="#fb7b03"
            android:textSize="18dp" />

        <ListView
            android:id="@+id/listViewProdutos"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/spnOrdenar"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp" />

        <ImageView
            android:id="@+id/imglimpar"
            android:layout_width="40dp"
            android:layout_height="30dp"
            android:layout_above="@+id/textView11"
            android:layout_alignParentEnd="true"
            android:layout_marginRight="10dp"
            android:src="@drawable/canpesq" />

    </RelativeLayout>
</RelativeLayout>

<ListView
    android:id="@+id/lv_sliding_menu"
    android:layout_width="200dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#FFFFFF"
    android:choiceMode="singleChoice"></ListView>

1 answer

0

Try to close the keypad via code when search view finishes

getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
);
  • I posted the code but it’s not working because I’m using android.support.v4.widget.Drawerlayout... I think that’s because I have a menu that’s in the upper left corner.

  • I edited my answer, with a code that you can close the virtual keyboard on the search response success

  • Thanks for the help friend I got with the following code ((Inputmethodmanager) getSystemService(Context.INPUT_METHOD_SERVICE)) . hideSoftInputFromWindow(edtBusca.getWindowToken(), 0);

  • Thank you very much

  • Cool, there must be other ways to solve it, but I believe this is the simplest and easiest

Browser other questions tagged

You are not signed in. Login or sign up in order to post.