I have an Activity
in Android, with two elements:
EditText
ListView
When my Activity
Add following in onCreate
method:
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
<TextView
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
style="@android:style/Widget.EditText"/>
For me, what worked on all devices is this:
<!-- fake first focusable view, to allow stealing the focus to itself when clearing the focus from others -->
<View
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
Just put this as a view before the problematic focused view, and that's it.
Simple solution:
In AndroidManifest
in Activity
tag use
android:windowSoftInputMode="stateAlwaysHidden"
The following worked for me in Manifest
. Write ,
<activity
android:name=".MyActivity"
android:windowSoftInputMode="stateAlwaysHidden"/>
The only solution I've found is:
android:focusable="true"
and android:focusableInTouchMode="true"
And the EditText
won't get the focus after starting the activity