Android keyboard only shows up once, but works perfectly when I remove the ListView



Current Behavior


Use the below xml layout, the android keyboard for the EditText immediately shows up when the activity starts. If I exit the keyboard, touching the EditText does nothing to bring the keyboard back.


Desired Behavior


When I comment out the ListView below, everything works perfectly. The android keyboard does not pop up immediately for the EditText, but rather only when I press it. I can also bring the keyboard back by touching the EditText.


Questions



  1. Why does the unintended behavior occur when I have the ListView?

  2. How can I keep the ListView and the desired behavior?


Side Notes


In both scenarios, I commented out all the Java code that dealt with the ListView, so this is not a programming issue. When I click the back button, and then come back to this activity, the keyboard pops up again (when the ListView is commented out).



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.mywebsite.myproject.PrivateChat" >

<RelativeLayout
android:id="@+id/form"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical" >

<EditText
android:id="@+id/message_input_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:background="#333333"
android:hint="Type a message..."
android:textColorHint="#FFFFFF"
android:inputType="text"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:textColor="#FFFFFF"
android:textSize="26sp" />

</RelativeLayout>

<ListView
android:id="@+id/private_chat_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" >
</ListView>

</RelativeLayout>

No comments:

Post a Comment