When an input is given focus, the default behaviour is for the soft keyboard to pop up.
In the example below, listFilterText is getting default focus (as it is the 'first' input in the layout) and forcing the soft keyboard to pop up.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/listSearchView"
android:layout_height="50dp"
android:layout_width="match_parent"
android:background="@color/DarkGoldenrod">
<EditText
android:id="@+id/listFilterText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="SEARCH" />
</RelativeLayout>
<ListView android:id="@+id/listView"
android:layout_below="@id/listSearchView"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</RelativeLayout>
The most strightfoward solution I have found is to manually give focus to a non-input object. We do this by:
android:focusable and android:focusableInTouchMode="true"<requestFocus /><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/statSearchView"
android:layout_height="50dp"
android:layout_width="match_parent"
android:background="@color/DarkGoldenrod"
android:focusable="true"
android:focusableInTouchMode="true">
<requestFocus />
<EditText
android:id="@+id/statListFilterText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="SEARCH" />
</RelativeLayout>
<ListView android:id="@+id/statListView"
android:layout_below="@id/statSearchView"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</RelativeLayout>
Now when the activity/fragment loads, the focus is given to the RelativeLayout and the keyboard will not pop up until the user activates focus on the EditText object.
For more on focus order see: http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-the-basics-of-control-focus-order/ http://developer.android.com/guide/topics/ui/accessibility/apps.html
by Shayla Sawchenko