I am new to Android and I am creating an app in which you have a form which you can save similar to how it is done in the contacts app.
My question is: how should I display "Cancel" and "Done" buttons? Should I even display a "Cancel" button in the first place, since the hardware back button (or the action bar's up-navigation) should suffice?
The screenshot below shows how it is done in the Contacts app, but I am wondering if this is "the way to go", because this way the buttons take a lot of screen space for no reason. On iPhone you have a small "Done" button on the top right (inside the navigation bar / action bar). I tend to do the same for this Android app, but I don't want to do anything that users don't expect.
So can someone please help me out here? :)
For this particular case, put the "Done" in a contextual action bar.
Back does not work as "Cancel" - it should also persist whatever edits made so far.
(Buttons like "Done" and "Cancel" are valid in an alert dialog but that is not the case here.)
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/
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.
I have an app that in a certain Activity (drawing) can be in any one of a number of states, such as draw, erase, select, etc.
To enable these states, I've got a button for each in the ActionBar, but one thing I'd like to do is to 'show' the user which state is enabled by keeping the button pressed active or pressed until I turn it off (when they have switched state by pressing one of the other buttons).
Searches here and other places have me coming up blank... can anyone recommend a possible solution? I've though about rolling my own toolbar, and while this might be my final solution, using the ActionBar would speed things up greatly at this point.
Thanks.
There is no direct way to do that, as far as I know, but you could implement your custom component to do that. However, my advice to you is having a separate toolbar that's not on the action bar, since the users expect all buttons on the Action Bar to be "Action Items" which perform something immediate, so having toggle items on the Action Bar might break this expectation. This allows you to save space on the action bar for things that the user expects to see there like: navigation, "Undo", "Save", "Delete"...
I agree with Bruno about the fact its probably best if you do it in a separate toolbar for the sake of user experience standard and your code will probably look better because you cant fully customize the action bar but if you do decide to go with it i can think of something really simple like, when clicking one of the menu buttons you set the pressed button to a new drawable (pressed button) and the others to their normal drawable (not pressed) so each menu icon will have a pressed and not pressed icon. you will have to invalidateOptionsMenu though.
I had the same problem and did not find a solution. However, I found a workaround that works for me:
In the onOptionsItemSelected(MenuItem item) method, if item is the button you want to toggle, simply call item.setIcon() and point to another drawable. I use the same image but with another color to show the user that the button is in "pressed" state. And when the button is pressed again, revert to the original drawable.
In my application I am having 3 menu like options,setting and favorites. In that If I press 'favorites' means it should display another set of (new)menu and I want to hide the previous set of (old)menu. IS it possible with android? If anyone knows, help me please.
I'm not sure if this is possible, but it's not the bast idea to do such things. Main reason - this behavior will be unexpected for user.
On selecting option menu item you should show alert dialog with possible choices.
Offtopic: According new design guidelines Android will delete "menu button", and all actions will appear on action bar. May be this will be better for your purposes.
I have a button that says "Sort" and when a user normal/short presses the button, I want a menu to appear with the various sort options. Looking around online there doesn't seem to be a straight forward answer to which route is considered best practice. I'm looking to have a menu that looks similar to this:
with icons and text.
For an example, click the Layers button in the Google Maps app. It opens a list of options on a single short click. It has a title at the top and icons for each option. (The icons aren't super crucial)
Should I use a Context Menu? If so, how do I do it without a long press. Should it be a Spinner? If so how do I change the appearance to use a button instead of the normal drop down box.
Spinners are for stateful selection, which sounds like what you want here. The user will select one sort option from a list, and there is a concept of a "current" sort that stays visible to the user.
For something like the activity picker in your screenshot, Falmarri's suggestion of an AlertDialog is reasonable. The difference between choosing a sort and the activity picker is the "stateful selection" distinction. Spinners have a concept of a currently selected item already provided for you, dialogs are more general.
http://developer.android.com/reference/android/app/AlertDialog.html