Excellent answers from Luc and Mark however a good code sample is missing:! -- Dummy item to prevent AutoCompleteTextView from receiving focus.
Excellent answers from Luc and Mark however a good code sample is missing.
1 This only works so far. If you are building a widget, you can't use the nextFocusUp hack, as you'll kill your ability to focus things above the widget. There's got to be some sort of initial focus resolution that takes place, as buttons won't get the initial focus, but an EditText will.
– Steve Pomeroy Nov 11 '09 at 20:24 Setting the focusable and focusableIntouch to true worked for me. Thanks a lot to everyone for sharing, It'd of take me ages to discover this ¿bug? ¿weird feature?
– Maragues Jun 21 '10 at 15:19 3 In case it helps anyone, this solution wasn't working for me until I put the dummy at the very top of the xml layout (still within the root element) – littleFluffyKitty Nov 11 '10 at 19:53 it's not help. :(( – Peter Aug 12 at 9:47.
I don't really see an issue with the EditText having focus on start, but it's definitely a problem to have the softInput window open when the user did not explicitly request to focus on the EditText (and open the keyboard as a result) If it's the problem of the virtual keyboard, see the AndroidManifest. Xml element documentation. Android:windowSoftInputMode="statedden" - always hide it when entering the activity or android:windowSoftInputMode="stateUnchanged" - don't change it (e.g. , don't show it if it isn't already shown, but if it was open when entering the activity, leave it open).
I realize this doesn't answer the specific question, but it's a very similar case and it answered my own question. Personally I sprinkled this across most of my Activities. Popping open the keyboard and squishing the view immediately is bad UI design.
The user needs context for what they're looking at before editing. – DougW Sep 16 '10 at 0:33 6 this is actually the better answer imo. – moonlightcheese Mar 16 at 23:30 2 This is a much-much better answer - this is the proper way to fix this problem, and not the hacky accepted solution.
– Artem Russakovskii Mar 30 at 21:39 1 Thanks, this is the real answer – Mina Samy Jun 14 at 11:05 3 Thank you! In case anyone want to do "android:windowSoftInputMode="statedden" programatically (via Java Code) integrate this call in the onCreate method of your Activity: getWindow(). SetSoftInputMode(WindowManager.LayoutParams.
SOFT_INPUT_STATE_HIDDEN)? ; – Ready4Android Sep 20 at 8:58.
I have the same problem. Tested the same - clearFocus() - without any result. Some solution?
Thanks :) Edit! The only solution I've found after the whole day is: Create a LinearLayout (I dunno if other kinds of Layout's will work) Set the attributes android:focusable="true" and android:focusableInTouchMode="true" And the &%$#~ EditText won't get the main focus after starting activity :).
Using the information provided by other posters, I used the following solution: in the layout XML in onCreate() private AutoCompleteTextView mAutoCompleteTextView; private LinearLayout mLinearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Mylayout); //get references to UI components mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.
Autocomplete); mLinearLayout = (LinearLayout) findViewById(R.id. LinearLayout_focus); } and finally, in onResume() @Override protected void onResume() { super.onResume(); //do not give the editbox focus automatically when activity starts mAutoCompleteTextView.clearFocus(); mLinearLayout.requestFocus(); }.
Try clearFocus() instead of setSelected(false). Every view in Android has both focusability and selectability, and I think you want to just clear the focus.
If I call it in onCreate(), the EditText still has focus. Should it be called in onResume() or some other location? Thanks!
– Mark Oct 12 '09 at 23:36 I combined the accepted answer with this answer. I called myEditText.clearFocus(); myDummyLinearLayout.requestFocus(); in the onResume of the Activity. This ensured the EditText didn't keep the focus when the phone was rotated.
– teedyay Oct 14 '10 at 21:02.
Try this before your first editable field: ---- findViewById(R.id. Dummyfocus). SetFocusableInTouchMode(true); findViewById(R.id.
Dummyfocus).requestFocus().
You can just set "focusable" and "focusable in touch mode" to value true on the first TextView of the layout. In this way when the activity starts the TextView will be focused but , due to its nature, you will see nothing focused on the screen and ,of course, there will be no keyboard displayed...
Yeah I did the same thing - create a 'dummy' linear layout which gets initial focus. Furthermore, I set the 'next' focus IDs so the user can't focus it any more after scrolling once: dummy. SetNextFocusDownId(et.getId()); dummy.
SetNextFocusUpId(et.getId()); et. SetNextFocusUpId(et.getId()); a lot of work just to get rid of focus on a view.. Thanks.
Late, but maybe helpful. Create a dummy EditText at the top of your layout then call myDummyEditText.requestFocus() in onCreate() That seems to behave as I expect. No need to handle configuration changes, etc.I needed this for an Activity with a lengthy TextView (instructions).
I use the following code to stop an EditText from stealing the focus when my button is pressed. AddButton. SetOnClickListener(new OnClickListener() { public void onClick(View v) { View focused = internalWrapper.getFocusedChild(); focused.
SetVisibility(GONE); v.requestFocus(); addPanel(); focused. SetVisibility(VISIBLE); } }); Basicly, hide the edit text and then show it again. This works for me as the EditText is not in view so it doesn't matter whether it is showing.
You could try hiding and showing it in succession to see if that helps it lose focus.
If you have another view on your activity like a ListView, you can also do: ListView.requestFocus(); in your onResume() to grab focus from the editText. I know this question has been answered but just providing an alternative solution that worked for me :).
If it's the problem of the virtual keyboard, see the AndroidManifest. Xml element documentation. Or android:windowSoftInputMode="stateUnchanged" - don't change it (e.g.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.