I'm using ListPopupWindow which I find very suitable for the purpose with one exception. I want to be able to detect when the user does other than select an item from the list or presses the back button. Currently what is happening is that when an item is clicked outside of the ListPopupWindow list I cannot determine what was clicked and the ListPopupWindow is dismissed. Ideally what I would prefer is for the user to only be able to select an item from the list or press the back button, however I cannot achieve that. I've searched for an answer and experimented for hours but I cannot achieve what is required. As far as I can determine, setting modal to either true or false appears to make no difference. I can obviously detect what is selected from the list, however whether the user presses the back button or clicks outside of the list appear to both dismiss the ListPopupWindow and I cannot determine the action that caused it other than an item was not selected. How can I either detect or prevent other than the user selecting an item from the list or pressing the back button?
As far as I can determine, this can be solved using
android.support.v7.widget.ListPopupWindow;
and
setForceIgnoreOutsideTouch(true)
Related
I m making book finder app.
step1: i clicked on search button and activity is waiting for my book title
step2: i input some book title
step3: the focus still stays on this search button, i have to click on screen to make it go away.
is there way to automatically loose focus on last widget i clicked on?
You probably just want to call requestFocus() on your book list whenever a search completes (however, if there are no results, you may want to re-open your search box, or do so after a delay). There is also a OnFocusChangedListener which might be of help if requesting focus on your list after serving up results does't work for some reason.
Hi there is thery any way to invoke a method that enables or disables the Touch Screen of Android?
I want this, because I have several buttons on my activity. When the user clicks on a button, it takes a few seconds to start the following activity, and because of that, while waiting that time, I don't want the user to be able to press anything.
I used a boolean that is True at start, then It changes to false when I click on the first button. And to every click on a button I check if the boolean is true...
But the problem is that Visually the user can click the button, it gets that look of being pressed..
So is there any good method that disables the entire touch screen ? And another that enables the entire touch screen ?
Thanks alot in advance ;)
But the problem is that Visually the user can click the button, it gets that look of being pressed
Disable the buttons, using setEnabled(false). This will not only prevent the user from clicking on them, but they will visually appear disabled, to let the user know that the user cannot click on them. It is important for the user to get the proper visual feedback about the buttons being disabled (and later enabled).
is thery any way to invoke a method that enables or disables the Touch Screen of Android?
Not really.
Is there a way to keep the search (widget or dialog) open even if the user clicks on the screen? I've seen many Google apps doing this (Keep, GMail, Youtube...) but not so many apps from external developers...
I have my search edit text visible on the ActionBar but as soon as I tap somewhere else on the screen, it is dismissed. I only want it dismissed if the user clicks on the action bar icon or presses the back key.
Is it possible? Thanks in advance!
Intercept the touch event on the container view.
Check if the SearchView is expanded.
If it is do nothing
Other idea, is cutting the SearchView being collapsed whenever the container sends touch event signals down to the view tree if it is already expanded. Or make sure it does not collapse when the SearchView looses the focus. Make sure you properly collapsed, when back key is pressed.
These are just ideas.
Hope it helps.
Could I detect if the menu pops up and someone clicks off the screen (closing it without selecting a value)?
Currently I have a checkbox that when clicked opens a contextmenu with choices. When I click off of it without selecting a value I would like the checkbox to disappear.
Thanks.
Should be, have you looked into the Reference Guide for onContextMenuClosed()?
I have an android application where I want to display a LinearLayout when user clicks on options button(I am setting the linear layout's visibility to visible in onCreateOptionsMenu) and make it invisilble when user clicks on back button.
This works fine when I press the option button and then the back button-the view comes up and then goes away respectively.
The problem is when I press the option button again, the linearlayout does not show even though the visibility is being set to visible.
However, log tells me that the methos onCreateOptionsMenu is entered.
Why would this happen?
onCreateOptionsMenu is called only once per activity. In your case you have to code in onPrepareOptionsMenu. This will be called every time the user presses menu key.
Why do you want do this? For android users relevant reaction for menu button is option menu.
What about question, try use View.bringToFront() - it will bring view in front of all views of the same parent.