I have implemented a listener : onFocusChanged to insert values in db when a edittext lose focus.
The thing is when I click the Send button (in action bar), it first do the action, and then it triggers a last onFocusChanged.
It should first lose the focus, and then execute the action?
Can anybody explain me that?
The solution should be giving focus to another button that is not edittext, but I just have a actionbar button, and it seems difficult giving it the focus.
Any suggestion will be appreciated !
I suspect that tapping the Send button isn't changing the focus at all (it is probably a nonfocusable view). What does your send operation do? Is there something at the end of Send which might be setting focus to some other view?
Related
Problem: In soft keyboard settings, there is a toolbar option, if we turn it on, it will give you some suggestions, for example, if a copied something, it will start appearing on the top of keyboard(marked red in the screen shot), if the user clicks that suggestion, it will be pasted on the edit text which have the focus.
Things i have tried.
override autofill method (not working, not called).
added text watcher, beforeTextChanged is called and the editable text is empty.
added the OnKeyListener (not working, not called).
added the onTextContextMenuItem (not working, not called).
Read bunch of questions on Stackoverflow but no question/answer is helping.
here is the screen shot:
PS: I am not sure how can i capture this click, and intercept the text, problem is that I am using the custom view for OTP, and when user click that suggestion, only first box is filled with the first character because we have max length equals to 1. I want to capture that text and fill it in my view accordingly. Any help is appreciated.
I have checked the following documents
https://developer.android.com/guide/topics/text/autofill
https://developer.android.com/guide/topics/text/copy-paste
I'm writing a custom EditText that will have functionalities to bold/italic/underline/lists .... for Android
It's working so far so good but I've a problem that when a user clicking on a Button (for styling bold/italic...), the user will lose focus on the EditText.
Anyone has any ideas how to prevent the button taking focus from the EditText?
Thanks :)
The easiest thing to do would be to have the onClickListener of those buttons refocus the edit text as their last instruction.
You can also try putting focusable=false (and focusableInTouchMode=false) on the buttons. That may work, I'm not sure if focus is removed from the edit text when the screen is touched or when another item receives focus, which is subtly but important difference here. It would also slightly change any drawables on the button that use focused state.
Most of the time (but not always), when I finish typing in a or and the soft keyboard hides, the view area is left raised with a black space on the bottom. Clicking, tilting or otherwise engaging the phone corrects the screen. However, user's first motion is usually pressing , but if you click submit it jumps down and you actually just click on the text area again. How do you stop this and get the screen to reset after the keyboard closes.
Take a look at you AndroidManifest.xml
http://developer.android.com/guide/topics/manifest/activity-element.html
I think you need to change android:configChanges.
I have the exact same problem what i did was handle hidekeyboard even in javascript and do something like window.scrollTo(0,0) or $("input[type=text],textarea").blur();
This will cause the the screen to get back to normal position
But there is just one problem when click from input field of type = text to a input field password it internally hide the keyboard which causes the hidekeyboard event to fire and scrolls the screen to top. This is the only side effect of this
Let me know if you find the solution for this
I have a ViewFlipper with several LinearLayout with EditTexts; after pressing a button, there's some validation done, and should it fail, I need to set the focus to the Edit that needs to be modified. vf is the ViewFlipper; et123 is an EditText. When there's an error detected, the following is executed:
vf.setDisplayedChild(5);
findViewById(R.id.et123).requestFocus();
The funny thing is that the first time the button is pressed, the focus goes to another element in the right Layout. If I press the button one more time, the focus goes to et123.
Any ideas on why does it happen or how to fix it?
Thanks
You might need to call
findViewById(R.id.et123).setFocusableInTouchMode(true);
Before calling requestFocus() to enable receiving focus.
At first my EditText had the focus as soon as the app loaded the screen and I disabled that with
android:focusable="true"
android:focusableInTouchMode="true"
However, there is no way to lose focus after clicking the EditText. The focus is still there when I try to click outside of the text area. This also happens when I click on the EditText to change the value and press "Done" on the on screen keyboard. Does anyone know a way for me to accomplish this?
Focus only changes if you click on something else that can gain focus. Issue is: If you click on a button for instance you might not lose focus, unless you do what Mathew said. Problem with that is: A button whose focusableInTouchMode is set to "true", needs now to be clicked TWICE: Once for gaining focus and once for performing OnClick. A nagging issue, that was haunting me as well right now.