I have a GridView displaying buttons to different screens of my app. When this grid screen, the first cell is selected. Is there a way to programmatically have no cells selected when the screen launches? Or do I have to hide the selector?
When this grid screen, the first cell is selected.
That should only be true if the user was using the navigator (D-pad, trackball, etc.) in the previous activity.
Is there a way to programmatically have no cells selected when the screen launches?
Generally, the user determines this based on whether they are in touch mode or not. You could try setSelection(-1) or something, but I would not be surprised if this fails to work.
Or do I have to hide the selector?
I would recommend just following the platform conventions. If the user is using the D-pad or trackball, they probably want to use the D-pad or trackball, and disabling the selector will simply make them frustrated with you and your app. Please see the article I linked to above for more details on touch mode and why it works the way it does.
Related
In my Glass application, I display a button on the toolbar. This button shows the on/off state of the camera and lets the user toggle the state.
The problem I am running into is that Glass occasionally moves the focus to the button. As a result, a tap keeps activating the button.
It seems Glass automatically converts toolbar menu items to live cards when top-to-bottom swing is used. This is nice. It gives the users the ability to select a menu item.
I am thinking if I could set the default state of the button to "disabled," it could solve my problem. However, this also results in disabling the button in the live cards. I would like to enable the button only during live cards.
Is there a way to achieve this? Or, is there a better way to remove focus out of the toolbar? Regards.
I have an app that works in the following way:
Upper part of the screen is the 'primary' part of the app, the actual content that the user can interact with is displayed here.
Lower part of the screen (maybe 1/4 of the screen height or so) is a navigation wheel. The user can turn this wheel to change the upper part of the display. When turned the entire upper part is replaced by something else.
These two part are implemented using fragments. The lower part (navigation wheel) is just a static fragment that displays a view hierarchy that can be rotated. The upper part (content display area) is a fragment as well, but it can be switched to other fragments when the wheel is turned.
Now what I want is that when the app starts, we are displaying a free content section, however when the user turns the wheel to one of the other content sections a window pops up to block the content display area, saying "buy this mode on Google Play." This popup should obviously block the content area behind it, so the user can see some of the display area behind the popup, but he/she cannot interact with it before he/she has completed the Google Play transaction. It would be nice if the views of the content area could be greyed out as well. The navigation wheel in the bottom of the screen however should not be blocked so that the user is able to navigate back to where he/she came from or further on to another content section. How can I make a popup that blocks the top view hierarchy from interaction but leaves the lower one intact?
As far as I know it is not possible to use the PopupWindow class to create a popup that will only block some of the screen behind it. It seems to always block it all.
Here is an of illustration the design. 'P' for paid and 'F' for free. On the second screen the app should ignore any press on the content section (behind the grey window), but the navigation wheel should still be able to turn.
Thank you.
On the second screen the app should ignore any press on the content
section (behind the grey window), but the navigation wheel should
still be able to turn.
You could make an overlay and set it up to eat all touch events(either by setting a OnTouchListener on it or by using a custom layout with the onTouch() method overriden to return true) and put it on top of your normal fragment content. This way the actual content will be visible underneath but will not receive any touch events. You could also add some content to your overlay right like in your image.
Also, as the overlay will only cover the paid fragment the wheel at the bottom will be touchable by the user(I don't know how that wheel actually interacts with your fragments so the approach above might not work).
I've made a small rudimentary sample as an example(you can find it here).
It would be nice if the views of the content area could be greyed out
as well.
You could make a recursive method to traverse the view hierarchy of your paid fragment and call View.setEnabled(false) on the views it meets.
Seems overly complicated to me.. I cannot imagine the design..
I would create a different fragment to be triggered if the user has purchased the item, with a different interaction, like a Dialog to be shown at every click, or something like that.
In pseudocode:
if wheel.position == 4
if itemPurchased
showFullFragment
else
showMockFragment
Create a default fragment with one button, that opens the right page of Google Play to buy the content. Then, every time the navigation wheel is turned, you decide in your code if you show the fragment with content (when user has finished the Google Play transaction) or you show the default fragment with just the button to Google Play.
Only one thing: Google Play is asynchronous. There might be some time when the user actually has finished the transaction but Google Play didn't inform your App, yet.
If the transaction was initiated you must decide if you show the content without having to 100% clarity that the user actually paid, or if you show a blank fragment. In any way, you should not show the button again, because that would confuse the user ("I paid! Why do I need to go to Google Play again???")
When you using standard Android keyboard on small screens, if you touch a button, you can see a hint, showing which button you hold now. How can I implements this on my custom set of buttons? Is the only way is creating pop ups on every touch event?
There is no built-in popup functionality for regular buttons in Android, so yes, you will have to implement this manually. However you don't necessarily have to create the popups for every touch event. I recommend creating one popup and changing its location and visibility on every touch event.
I've created a custom IME for Android tablets and I'm having trouble resizing when the screen is in horizontal orientation. Whenever an EditText is clicked while the screen is horizontal, the IME takes over the entire screen with the standard EditText and Button combo with my custom IME at the bottom of the screen. However, I'd like for the IME to simply pop up without that and type directly into the field that was originally clicked, as it does in horizontal orientation. I've looked at the SoftKeyboard example, which accomplishes this (at least on honeycomb) and can't find exactly where they are setting that effect.
Sorry if this is a duplicate, I've tried searching but couldn't find this exact question.
If anyone else is having this issue, you can prevent your IME from entering fullscreen mode by overriding the onEvaluateFullscreenMode() method, which is what determines whether or not your IME will display in full screen.
Now I'm having different issues but that's for a different thread!
I use setEnabled on RadioGroups, EditText, Spinner, and Checkbox. However when I do so the data is very dark to see (have to squint at it). How do I make it so that the disabled controls can be viewed easily by the user AND have it differentiated from the editable mode controls.
You would have to provide the drawables for the background of each control. You'd probably want to implement a selector to change the image based on the state.