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?
Related
I looked for the question everywhere on the Internet but can't find the answer. What I found is to hide the whole button tray all together.
When the keyboard is down, the button is shown as in the picture.
But when the keyboard is showing the icon changes to -
My problem is to change the button (as in the second image), when my emoticons are showing. So, is there any way by which I can programatically change the button on an event and change it back on another event?
I'm afraid this is not possible yet. Perhaps this will be implemented in later versions of Android.
Not all devices have an onscreen navigation bar, a lot of devices still have hardware buttons.
Nevertheless, you'll might find this article interesting: http://arpitonline.com/blog/2014/07/27/improving-androids-navigationbar/
I have a EditView. When some one clicks on the EditView, the only way the keywbaord will go away is if the back button id press.
I saw some apps have it so when the keyboard comes up, there is a button that says done in the lower right hand corner. When this is press the keyboard goes away.
My app does not do this, does anybody know how they did this?
Also is it possible to have the keyboard go away when the enter key is press, insrad of having it add another line of text?
You can either use TextView.setImeOptions() and pass it actionDone or use the android:imeOptions="actionDone" attribute in your layout.
To close when enter is pressed, use a custom OnEditorActionListener. However, it would probably be better to change the enter key to done as above so as to convey what action will occur.
See this SO question.
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.
Is there a way to find out when did a user click "Setting" options on the screen menu?
The onClick listner's KeyDown events catches only the hardware buttons on the phone and not the clicks of the sofware keyboard that shows up when a textbox/editText gets a focus and the key guard shows up.
Is it even possible using public android SDK.
P.S. : I am only concerned with 2.2 and 2.3 so its fine if this is not possible on 3.0 and above.
Thnx
EDIT
Explanation of a scenario that will help understand the question better!
I have a full screen activity with a editText and a button. I want to intercept all the clicks that a user make and based on that make some decisions.
I am able to register a listner to intercept what phisical keys are being clicked(HOME, MENU, VOLUME UP/DOWN etc)...The problem is, when the user clicks on the editText i.e. the text box gets the focus, the sotware keypad shows up. Now I also want to intercept what keys(numbers, alphabets, special characters or even custom functions on some samsung android phone like 'Go To Settings' are clicked and perform action based on the clicks.
My question is, is it possible and if yes, then how?
NOTE: Please dont ask me why am I doing this because its bad user experience. I am very much aware of that. I am trying to do this in a particular context that needs this functionality. Thnx!
You need to use the KeyListener class and setKeyListener
http://developer.android.com/reference/android/widget/TextView.html
This only allows you to modify/filter input into the TextView.
Maybe this question has been asked already but I can't find any information about that even in the "Menu" section of Android's doc...
So does anyone know if there is a way to set the menu out on an activity (to avoid the user clicking on the menu button of the phone)...?
Is this what you are looking for Sephy ?
Activity.openOptionsMenu()
I'm not quite sure what you are asking. The menu button is often a physical button on the phone, so you can't make it invisible if that is what you are asking. You can refrain from adding items to the menu. Then clicking the menu wouldn't do anything.