I've some settings page in my app. Once the activity gets starts directly it focus to edittext and i used following code to clear foucs.
<RelativeLayout
android:id="@+id/RequestFocusLayout"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
and in java code
RelativeLayout focuslayout = (RelativeLayout) findViewById(R.id.RequestFocusLayout);
focuslayout.requestFocus();
The above code is working fine when activity starts at first time and if same activity starts again, automatically edittext get focus.
Can anyone help me to solve this issue.
In the layout XML file, specify an imeOption on your EditText:
Next, add an action listener to your EditText in the Activity's java file
Where mYourEditText is an EditText object
Put the code to remove the focus in your onStart() method and it should work fine.
put these line onStart() or on onReusme()
Me realy help only
android:focusableInTouchMode="true"
in my parent view group.I used the solution shown up in this page but it didn't work. Add this attribute to your activity tag into AndroidManifest:
It works perfectly.
If your EditText is a child of your RelativeLayout you can use
android:descendantFocusability
to request the focus: