What I want
A simple EditText. User should be able to enter text at any point of time.
onClick of this EditText, a popup should appear anchored to the EditText.
onClick of this EditText, if popup is already being shown, then dismiss the popup.
This popup will contain a list of items (that i decide and no filtering) on clicking of which the EditText will be filled with the clicked item.
When I start typing, the popup should go away.
I should be able to set the animation of the drop down list.
What were my options
Obviously, AutoCompleteTextView. Worked great after customizing AutoCompleteTextView. But there were two problems?
I was able to accomplish points 1, 2, 4 and 5. How do I get around this number 3 and number 5?
Since nothing worked...
I thought I can just put a edit text and show a popup window. :)
But that fails utterly...
I just tried to do the simple way. I added a EditText. And then I created a class of PopupWindow and inflated a listview in it. Then I anchored it to my EditText. Now the problem starts again -
I click on the EditText. The popup appears. Takes all the focus and the keyboard goes away. Definitely not what I want. So i made the popup window not focusable.
And now I click on the EditText, the popup appears. Doesn't take the focus. So keyboard stays to take input. Just perfect like I want. But when I click a list item in the ListView, it doesn't do anything. Why? It is not focusable!
So what do i do now? Which way do I go?
For 3. you can create an onFocusChange listener, or and onClickListener and explicitly call _autoCompleteView.dismissDropDown();. You can use isPopupShowing() to see if it is already showing and manually dismiss it in that case.
For 5. you just do the same thing but you do _autoCompleteView.registerDataSetObserver and put that logic in the onChanged() event or possibly in the addTextChangedListeneron your autoCompleteTextView.
I am not entirely sure if this is the functionality you were looking for but this thread is almost a year old now so maybe it will be helpful for someone in the future.
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
In the default activity created by Android Studio, I added android:textIsSelectable="true". Now, if I long-press a word, it shows copy/share/select all, but when I tap elsewhere, it does not get closed. I need to either click the back button or select one item on the menu. How can I make the menu closed when I tap somewhere else?
There was the (probably) same question (although the questioner did not specify that it was a TextView, I think it was), but the only answer was assuming an EditText and talk about dismissing the software keyboard (which is not needed for TextView) and solving the problem by adding a listener to all views other than EditText. Seems kind of a dirty way. Is that the only way?
I'm using the v16 API and having problems with where the popup is being placed when the onscreen keyboard is displayed.
The first problem is that if the EditText is at the bottom of the screen, when I touch the field to open it for editing the popup is displayed below the control and the immediately covered as the keyboard appears. It doesn't reposition itself above the EditText until a keypress triggers my validation code to fire again on the new value.
The second problem is that when I close the keyboard and the ScrollView containing the text scrolls back down from where it positioned itself to show the EditText above the keyboard the popup remains placed on the upper half of the screen instead of where the EditText is until I touch something else on the screen (triggering the ScrollView to do a redraw???).
Unfortunately that popup has various problems like this :(
Perhaps a simple solution in your case is to forcibly invalidate the UI when the keyboard has displayed and dismissed? Can't recall if the Popup will reposition if the EditText is invalidated, but worth trying as the alternative may be to re-implement.
Checkout my android-formidable-validation lib on github, it re-implements...though has its own problems - if you go down that path, why not give me a hand with some contributions ;)
I have list of products which have EditText in TableLayout.
I want Keyboard in right/left of EditText and it needs to be containing 0-9 ,.(dot) ,Delete,and Done.Don't need other keys.
Each time when the user click EditText, it will show key pad to right of EditText (trigger/onClickListner).
Currently I did Like this:
How we can implement.
And normal list is :
I want keypad right of /left of text-box.Keyboard may be user define/predefine.How we can implement these.
I have created one keyboard.Its always display the bottom of the screen. I need right of textbox or left.
How can i set the keyboard coordination. Please tell me...
I don't have any idea on how to do this. I want to implement this.
My created keyboard width & high is too small than default.
Please advice me / guide me on this.
How can i set the keyboard coordination.
If you are using your custom Keyboard you Can't locate it at your desired position. By Default it will appears at the Bottom only.
So you can try with Custom Pop up window , Another Post for your requirement.
You can try with Quick Action Dialog for you requirement
Also check this Touch Calculator Source for you reference.
I have a layout which has one large EditText view at the top + a bunch of buttons at the bottom. The EditText is made to shrink and expand when the ime is activated/deactivated by using adjust_resize. The buttons at the bottom are pushed up above the ime.
I would like to hide these buttons when the ime displays, to provide enough space for the EditText view.
I have so far tried the following:
subclassed EditText and provided the activity the option to register a callback on the view's OnSizeChanged.
Used this callback to change the visibility of the buttons (actually the layout container) to GONE.
This work OK and does hide the buttons when the ime pops up.
However, the EditText does not expand into the new available space.
Furthermore, when the ime is disposed off, the EditText field is now bigger than it was originally, pushing (the now showing) buttons outside the screen.
I should also add that when typing the first letter into the view, and the ime displays the word options, the screen is redrawn and the EditText fills the vacant space.
Any ideas on how to get this to work?
Or even better, is there a simpler solution to my requirement?
Thanks...
NB: In my view, scrolling is not a good option.
I got this to work by changing the above method a bit:
Wrapped the entire layout with a FrameLayout
subclassed the FrameLayout and provided the activity the option to register a callback on the layout's OnMeasure
This gives the activity a chance to change visibility of views before these are measured.
I would still be very happy to hear about simpler solutions, especially in regards to figuring out whether the keyboard is currently visible or not.
(dumpsys window shows this information. Can we easily get to it?)
Have you tried to call myView.invalidade() ?
I was using the GONE property, but then changed to button.setVisibility(View.INVISIBLE); because I don't have any other stuff on my screen.
on the adjust_resize, you will need to check again when the keyboard has gone and show the buttons again.