I have an activity
with a search box (EditText
) on the top, and a ListView below. Whenever the activity starts, the EditText always has focus and bring up the keyboard which partially cover the ListView
.
There's no other text view
that can have focus.
I want the EditText to have focus ONLY when the user touches it and start typing. I try to put clearFocus() in onCreateView
, onViewCreated
or onCreated
, but no luck.
you must have mentioned
<requestFocus>
tag in youreditTiext field
in XML remove that and run againYou can try this:
where ever you want to clear focus.
This will do your work:
android:windowSoftInputMode="stateHidden"
Add the android:focusable="true" and android:focusableInTouchMode="true" elements in the parent layout of EditText as follow;
I think, it should help you.
Try this
On your
Activity
Declaration inAndroidManifest.xml
add the below code :It will prevent the keyboard to popup up when activity becomes visible.
Happy coding :)
Here is the answer EditText, clear focus on touch outside.
Or you can just write widget which will show only text with textView and
onClick
will display dialog withEditText
where you can edit this text/