How will it be possible to have a menu button which call option-menus with the following condistions ( must be ):
App hides the titlebar :
requestWindowFeature(Window.FEATURE_NO_TITLE);
the targetversion in Manifest is set to 16 :
android:targetSdkVersion="16"
Some Infos and researches from my side:
Setting targetSdkVersion="10" shows the menu still in the bottom, which I would like to achieve.
Showing the titlebar shows the menubutton in top ( 3 points icon ) and the menu is also callable. But I need to hide the titlebar.
any hints , suggestions ?
thanks & regards
Andreas
Another option is to use slider menu and have it on left or right. You shouldn't include button on action bar (like facebook), you can open menu after item click or onFling event.
There is nice and easy tutorial that I tried:
http://oodlestechnologies.com/blogs/Facebook-Style-Slide-Menu-In-Android
Related
I am having problems getting my in-app menu navigation to work. Unfortunately, I have not been able to find a solution here so far. Since I'm quite a newbie to Android development, I'm not sure what info you guys need for better assistance, so bear with me.... ;]
Problem:
The "back to main menu" submenu option triggers the menu.performIdentifierAction(R.id.back_to_main_menu, 0) action. This works fine in principle, but only once. So, suppose the user navigates from the main menu to submenu A, he can return to the main menu and also go to submenu A again. But if he now wants to return to the main menu for the second time, the entire menu will be completely closed. Then the user can still click on all items, but the "Return to main menu" option does not work and instead simply closes the entire menu.
All other methods/actions associated with the menu items will be invoked properly.
What I tried so far:
I tried closing and inflating the menu again. But it lead to different other problems mostely due to not being compatible with MaterialToolbar and using an optionsMenu and related functionalities instead.
Also the solutions I found for selecting a specific menu element programmatically were about using the above mentioned method "menu.performIdentifierAction()".
App structure:
My app consists of three activities and one background service. In all activities I use the same xml menu. And the behavior is the same in all activities. The in-app menu consists of several items and submenus. In each submenu, I added a "back option" so that the user can return to the main menu without closing and reopening the menu.
The menu is included in the activity xmls for each activity, like (simplified):
\<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout_mainActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"\>
<com.google.android.material.appbar.MaterialToolbar
android:id="#+id/materialToolbar_mainActivity"
style="#style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="#menu/material_toolbar_settings"
app:title="#string/page_title_mainActivity_text" />
</com.google.android.material.appbar.AppBarLayout>
Referenced like:
materialToolbar_mainActivity = findViewById(R.id.materialToolbar_mainActivity);
Clicked item handling like (simplified):
materialToolbar_mainActivity.setOnMenuItemClickListener(menuItem -\> {
// handle item selection
switch (menuItem.getItemId()) {
// ...
case (R.id.item_mainMenu_app_info):
showInfo();
return true;
// ...
case (R.id.item_submenu_backToMainMenu):
materialToolbar.getMenu().performIdentifierAction(R.id.item_main_menu, 0);
return true;
// ...
default:
return false;
}
});
If you have any suggestions or solutions, please don't hesitate and let me know. If you need any further information, please let me know as well.
With kind regards
i am using Appium(java) to test android app that contains pop-up window ,(pop-up appears after clicking a button..)
the popup compose from :
Framelayout with resource-id : android:id/content
LinearLayout with resource-id :android:id/parentPanel
LinearLayout (contain 2 buttons) with resource-id :android:id/buttonPanel
i want to press 1 of the buttons inside it ...
i tried verity of options that i found on the web , but nothing works
you can use self.driver.find_element_by_name("text to be clicked")
Problem : It is not possible to simply 'add' ContextMenu to a Canvas or Pane element via addContextMenu(menu), which works only with javafx.scene.control elements (and neither Canvas or Panel extends this class).
Question : Is there any 'clean' way to 'register' ContextMenu item to a Canvas element? I expect standard behavior of this menu (to show after RMB clicked on Canvas element, autohide when clicked with LMB etc.).
Canvas canvas = ... ;
ContextMenu menu = ... ;
canvas.setOnContextMenuRequested(e -> menu.show(canvas, e.getScreenX(), e.getScreenY()));
James_D's solution may not dismiss the menu when clicking the canvas while the context menu is visible. See this bug :
https://bugs.openjdk.java.net/browse/JDK-8095591
So instead, I suggest using :
Canvas canvas = ... ;
ContextMenu menu = ... ;
canvas.setOnContextMenuRequested(e -> menu.show(canvas.getScene().getWindow(), e.getScreenX(), e.getScreenY()));
Maybe you can use Chrome extension's contextMenu. here is the official document.
The only issue so far I find is that the Context type for a canvas is not clear. ["all"] works but is not a good way.
Action myAction= new Action("LABEL", ImageCache.getImageDescriptor("IMAGE"));
This code shows me a button without any text. Instead it only shows the image.
What should I do to display them both side by side?
I tried using setText() and setDescription() and setImageDescriptor() but none helped.
Text is not normally shown for an action in a ToolBar if there is also an image.
If you are adding the Action to the tool bar manager using an ActionContributionItem you can call ActionContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
I want to add a a menu item to the top (Where the class title is). I added the item to menu.xml and also for made an Intent to open a new class after clicking but it does not open my whole app anymore. And when I remove android:onClick:"history" it starts working again with out the menu function of course.
Have a look at the picture please: http://snag.gy/udxXc.jpg
That 'History' is my button that needs to open a new class. and this is my code:
xml:
<item
android:id="#+id/history"
android:showAsAction="always"
android:title="History"
android:onClick="history"/>
Java:
public void history(View view){
Intent historyIntent = new Intent(this, History.class);
startActivity(historyIntent);
}
Am i doing it correctly? or any better solution?
I want to add a a menu item to the top (Where the class title is)
That is called the action bar.
And when I remove android:onClick:"history" it starts working again with out the menu function of course.
I am not aware that android:onClick is valid for <item> elements.
Am i doing it correctly?
Not as far as I am aware.
or any better solution?
Override onOptionsItemSelected() and respond to the item click there.