I have a simple EditText
over a ListView
defined below.
When the app runs, the EditText is selected and the keyboard appears.
I don't want that to happen. I don't want it selected or the keyboard to appear by default.
<EditText
android:id="@+id/search_box"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="type to search titles"
android:inputType="text"
android:maxLines="1"
android:capitalize="none"
android:linksClickable="false"
android:autoLink="none"
android:autoText="true"
android:singleLine="true" />
<ListView
android:id="@+id/DetailsListView"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="@color/transparent"
android:cacheColorHint="@color/transparent"
android:listSelector="@drawable/list_selector"
android:fastScrollEnabled="true" />
First the tag is monodroid so it's on C# so the accepted answer is correct.
But is not what I think the author wants... this trick just hide the keyboard but the editText still have the focus.
To do this both in java and c#, you have to put this in your root Layout :
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
For example :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
>
....
</LinearLayout>