What I want to do, is to create a menu with checkeable items like this:
But just after clicking a button or icon in my main activity, so I can have different menus like this depending on the button which I click. I don't know if this is the right component or what I have to do.
I would just need a sample with a button and after clicking it, it creates this kind of menu with some options.
Thanks in advance.
There's several ways to accomplish this. One way would be to have a layout that you want to use for it and use a PopupWindow. This will create this type of look. You will just create the contentView to go inside it.
Another way, especially if you need more functionality, would be to create a separate Activity with a Dialog theme and put a ListView or whatever you need. But for what you have shown, a PopupWindow should work nicely for you
Related
I wanted to create an options menu as seen in this image: http://i.imgur.com/Mf0PSy8.png
But the problem is, the only way that I found to create this type of menu is by calling onCreateContextMenu method and I don't want it to only appear when user long-press an item.
I want it, for example, to show up when user click a specific button linked to a function.
How can I do it?
You can explicitly show the option/context menu programmatically by calling Activity.openOptionsMenu() / Activity.openContextMenu(View view).
You're looking for a Dialog Fragment. These work just like a Fragment class but can be displayed as a dialog. You can find more on using a Dialog Fragment in this tutorial to do whatever you would like
I am working on a simple application that is supposed to work on 800x480 tablet. Currently:
[][][][]
[][][][]
OOO
These are all buttons and they are working as expected. I, however, need to add menu items to the bottom-buttons. When clicked, menu items should pop up.
-Can I create a menu and place it at the bottom of the screen to replace those buttons? If so, could you show an example, cause I couldn't find any.
-Or, can I add menu items to these buttons?
What You want is an OptionsMenu, if I understand You the right way. I could give You an example later, I am not at home. But for now, look at this example. If You follow this, You donĀ“t need those buttons at the bottom.
http://www.edumobile.org/android/android-beginner-tutorials/options-menu/
if it is not clear, just let me know and I try to give You an example at the evening...
EDIT
for custom menu, You could use PopUpMenu. I had not tried this for now, but I think it is a good solution
http://android-er.blogspot.de/2012/03/example-of-using-popupmenu.html
Is it possible to create a menu in android that shows when someone for example touches a graph and It brings more options. I want a menu that will appear from above and below like how the menu used to be in android when you touch the menu button. Now without the button i would like the user to touch a chart or a table and two menus appear from above and below or even sides. Any suggestions will highly be appreciated
Suggestion:
Make the layout of menu you would like to show, and include it in the layout of your activity.
By default set it to be GONE, this will hide it.
Then set a touch listener for your graph, and change the visibility of menu to VISIBLE to show it.
I think what u need is a context menu; see this example Hope this helps :) cheers :)
I have an Activity which provides UI for editing entity properties such as name, description an so on. This entity can also have an icon but (this is the main problem) can have no icon. I have created an icon picker activity which provides UI for icon selection. But I can not think of a simple and pretty way to provide access to this picker from parent activity. It could be a simple image button if the task was just to select an icon but I have also to make it possible to remove already set icon. Having two buttons with 'choose' and 'remove' seems ugly. Any smart ideas?
UPDATE
I've ended with ImageButton showing selected icon or special 'No' icon if object has no icon. On button click I show PopupMenu on 3.0+ and ContextMenu on older versions. Menu contains 'Change' and 'Remove' items.
You could have a border that surrounds an empty space or the image if there is one already.
If the image exists, clicking on it brings up a dialog where you can choose to change it or remove it.
If it doesn't exist, clicking on it brings up a dialog where you can add it.
how about a gridview within a custom dialog fired from your parent activity??
change the icon onItemSelected() of the gridview??
I've read through all of the android documentation that I can find but I'm still not clear on whether a button can be added to an application for an android device somewhere outside of an options/context menu. It seems like all of the menu buttons are only accessible either from a tab bar at the bottom or the menu button on the device. Is this correct?
I'm not sure I understand what you mean, but you can use a Button widget in an activity anywhere you want, just like any other widget type. See:
http://developer.android.com/reference/android/widget/Button.html