Is there an easy way to change the ActioMode "Cancel" button text? - java

I am using ActionMode to show a list of context functions for a ListView. I have the ActionMode bar working but by default it puts a "Cancel" button on the upper left side. To me this is a little misleading to users. I don't want them to think this button will undo the action.
Is there an easy way change this buttons text to something like "Done" or "Finish"? I looked through the source and found that this seems to be tied to a theme style. I was hoping not to have to modify the theme but can if needed.
I am targeting 3.2 or later.

I am reasonably certain that this can only be adjusted using a theme. Certainly, there are no methods on ActionBar or ActionMode for making this change. One hopes that it is at least possible via a theme -- I did not try sifting through all the theme stuff to find the actual value to change, and so it's possible that it simply cannot be changed at all (which would suck).

Related

What's the most efficient way to change the overall theme of the app?

So I got an idea for an app that would change visual theme based on user's selection, something like how a Sub-Reddit would have the option for users to switch between themes. In this case, I would utilize at least 4 themes, each theme changing the color of certain views, such as the background, buttons, image, and etc. I would like to know the the best approach to this. Do I need to keep a list of views that would be affected or something?
I've tried keeping different button backgrounds with different color since setting background color programmatically would reset the background shape back to the default design, but I'm afraid that it will cause the app to be bloated with numerous files. I've tried using the color filter to change the views.
Color id still keeps the filter applied to it, causing it be unusable if user switch to different color, then back.
Hopefully, this question was directed at native development. If so, then you should take a look at the guidelines. You can create your themes in XML and reference them in your layout XML files.
Personally, I would store the theme as a SharePreference somewhere and then when laying out each Activity/Fragment, utilize the user's saved theme.

Android UX flow, next button on ActionBar

I am in a UX flow conundrum. In the ActionBar http://developer.android.com/design/patterns/actionbar.html, I am tasked to place a 'Next' button similar to that in iOS.
I am aware that Android has no equivalent button for that, is there a suggestion?
I would say it depends on your needs. Generally apps with a need for a Next button put it somewhere near the bottom-right of the screen.
I would personally be against putting it on the ActionBar as some devices handle it differently. Older devices might end up putting it behind the Menu button, and you'd have to be careful not to let it go into the overflow '...' menu as it may be too hidden-away in there (again, depending on your use case).
The other thing to remember is that putting it on the right of the Action Bar suggests that the button on the left of the Action Bar is a 'back' button, which is is not (It's an 'up' button).
I'm thinking more something like this:

How do I toggle the menu button icon and tooltip text for an Eclipse plugin?

I'm developing an Eclipse plugin that has a toolbar menu item that will be enabling/disabling a feature. I know how to set the icon and tooltip text for it using the plugin.xml file, but I want to be able to change the icon and especially the tooltip text for it depending on the state of the project being worked on. I.e., if the feature is not enabled, I want an icon that shows turning the feature on along with tooltip text that says "enable feature", but if the feature is enabled, I want an icon that shows turning the feature off along with tooltip text that says "disable feature". Right now, the only option I can see is a generic icon and tooltip text that says "enable/disable feature", but that feels clumsy to me.
Edit to add: In response to indigomonkey's answer, which is a good one based on what I originally wrote, I would like to clarify that the behavior that is being enabled by the toolbar button is one that we really discourage ever disabling once it has been enabled (and a dialog pops up both to when enabling it to verify that they want to enable it because it should not be started lightly as well as to discourage them from disabling it once it is enabled). Because of this, I would like the icon to change to one that suggests "don't click on me".
If your command Handler implements IElementUpdater the updateElement method will be called whenever the command is run.
The UIElement parameter of updateElement has setIcon and setTooltip methods.
I would suggest that you choose to create your toolbar contribution as a 'checkbox' type, rather than the standard 'push'. This will mean that the button will toggle between a selected and unselected state, allowing you to equate this behaviour to the enabled and disabled state of your feature.
If you're using org.eclipse.ui.commands and org.eclipse.ui.handlers along with the org.eclipse.ui.menus extension point to contribute your button with a <command> element, you'll need to set its style attribute to check. You can then read and toggle the command's selection from inside the handler.
For more information, see http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html.
In rcp E4 the solution seems to be a bit different. Since I first stumbled accross this question, I want to summerize/link the solution for future developers.
The relevant questions, where I found the answer are Switch Image of a Handler in a e4 rcp and RCP 4 Toggle a button in the toolbar.
Basically you need to add the argument MToolItem to your Execute-method like this:
#Execute
public void execute(final MToolItem item)
{
item.setIconURI("platform:/plugin/......");
//additional changes e.g. to the tooltip are also possible.
}
If you additionally give your toolbarbutton type checked
<elements xsi:type="menu:HandledToolItem" type="Check" ...
the item will automatically toggle between selected/unselected with each click. You can get the current state with
item.isSelected(). As a side effect, the toolbar icon will be highlighed in the selected-state. If you don't want that, you need to keep track of the state yourself.

How to change the style of an Android widget button programmatically?

I would like to change the style of an Android widget button (specifically the corners) completely programmatically. Meaning, I would like to do it without any xml files at all. From my research I am coming to the conclusion that this is not posible. Is my conclusion correct or does someone know how it might be done?
You should look at the inherited methods from TextView and View of Button:
setPadding(int left, int top, int right, int bottom)
to name one... you can also change the layoutparams of the button object, which gives you access to all the xml attributes normally accessible. In general, you can do everything programmatically that you can do in the xml.
If that isn't enough, you can extend the Button class and override the onDraw method to change how android draws your button
EDIT:
Maybe you can add an xml theme much like this thread suggests: How to programmatically setting style attribute in a view
and then in it set
and add the theme programmatically to the button?
I haven't done much work with themes, so I can't attest to whether this will definitely work
Why do you think this is the case? Taking one of your items as an example, here's a method to set padding.
For corners you can use a drawable with a shape with rounded corners. See the documentation for drawables. There are also many questions (with answers) on StackOverflow about this too. If you want to do it programmatically there is the RoundedRectShape.

Java Menu issue

I have a menu with a few JCheckBoxMnuItems. How do I ensure that the Menu stays open until I have done all my selections (i.e. checked the menuitems) and does not close on just clicking one of them?
I'd rather not try to change the normal menu behavior for an application or for a part of the menu tree. A User expects that the menu closes automatically after a menu item is clicked. And, if you kept the menu expanded, what kind of action would you invent to close it manually after you've done your last selection?
If there's a requirement to change more then one setting within one use case, then you should consider to provide a small dialog where the use can apply the changes and confirm them at once. I believe, that's more consistent with typical behaviors of UIs.
And it declutters the menu bar, you'll have just one 'setup' menu item instead of a dozen (?) check box actions :)
I guess menu's aren't supposed to allow multi-selection.
But you may offer keyboard shortcuts to set the menuitems without using the menu at all.
If the set-operation of your flags is a central aspect in your application, I would tend to use a dialog here. These are all suggestions which do not require to change the internal implementation of the existing controls, even though I know, that it would be possible in swing.
I agree that it is better to do this with standard UI. However, if do you want to add checkboxes that do not close the menu it is surprisingly easy:
JCheckBox checkBox = new JCheckBox("Text");
checkBox.setOpaque(false);
checkBox.setRequestFocusEnabled(false);
menu.add(checkBox);
This may not work on every look and feel and the check boxes will not line up with menu items in the same manner as JMenuItems but it seems to be a reasonable place to start.

Categories

Resources