Display options menu using onClickListener - android-optionsmenu

I was just wondering whether it is possible to display my options menu to be displayed when I click on a image. Now I have displayed my options menu when the menu button is clicked. But I would like to display it when the user clicks on my imageView too. Is this possible?

I found this to be so simple at last.
imageView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
openOptionsMenu();
}
});

Related

MudBlazor: how to display notification in Bottom-Right of window?

I have created an app using MudBlazor template.
All is ok, I use MudBlazor Snackbar and in MainLayout I use
and button on it.
On click I call a function
ShowNotification("BottomRight")
private void ShowNotification(string position)
{
Snackbar.Clear();
Snackbar.Configuration.PositionClass = position;
Snackbar.Add(message, Severity.Normal);
}
I'd like to show notifications in the Bottom-Right of the Browser window but it displayed in left top corner because it is MudAppBar.
How to display notification in the Bottm-right of browser window?
You should not be using "BottomRight" but Defaults.Classes.Position.BottomRight instead:
#inject ISnackbar Snackbar
<MudButton
OnClick="#this.ShowMessage"
Color="Color.Success">
Show message
</MudButton>
#code {
void ShowMessage()
{
this.Snackbar.Clear();
this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
this.Snackbar.Add("Wazzup?", Severity.Normal);
}
}
Demo: https://try.mudblazor.com/snippet/wumnYmbNHjwLplPt

I want to set an onClick listener for custom view in sketchware

{final Button tab3button2 = view findViewById(R.id.button2); View.OnClickListener() { #Override pubilc void onClick (View v)
I have tried searching for answers but all to no avail.
Just copy the code for on click on source code, and you must have a section like bindview or webview to get at the id of widget. Then just enter I'd, make sure it's different then all others on same page.
Here is what you need, I edited your code:
final Button tab3button2 = view findViewById(R.id.button2);
tab3button2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View _view) {
here put the blocks that will be executed when the button gets clicked
}
});
it's recommended to add this code in the onCreate event, but if this Button is in a ListView custom view then add it in the onBindCustomView event.

Custom tab item

I need to add a custom tab item into my TabbedPage. That shouldn't be a page but an overlay view. It is "More" item for the bottom menu opening a more items menu over the currently shown page.
So far I found the following solution:
protected override void OnCurrentPageChanged()
{
base.OnCurrentPageChanged();
if (this.isInitialized)
{
if (CurrentPage.Title == "More")
{
CurrentPage = this.lastSelectedPage;
}
}
this.lastSelectedPage = CurrentPage;
}
It's enough to prevent opening the corresponding fake page. After this I need to show an overlay view and have no item how to do it from the tabbed page.
Another solution I'm working out now is to write a custom renderer for my tabbed page and manage all the custom work there. The question in this case is how to show my custom view over the existing content. I tried AddView (iOS) in the renderer but getting runtime exception.
public override void ItemSelected(UITabBar tabbar, UITabBarItem item)
{
base.ItemSelected(tabbar, item);
var view = new UILabel()
{
Text = "Test"
};
View.Add(view);
}

GWT Propagate event through AbsolutePanel

I have a CellTable with ClickableCell. When I click on it, a popup opens and show the clicked cell table as exepected. The CellTable is added in a AbsolutePanel(Parent).
For some developpment, an another AbsolutePanel(Over) is located over the CellTable.
How can I propagate the AbsolutePanel(Over) click event on the celltable ?
I had an handler on the AbsolutePanelHandler(Over) and fired the clicked event :
absolutePanelOver.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
NativeEvent nativeEvent = Document.get().createClickEvent(0, -event.getScreenX(), event.getScreenY(),
event.getClientX(), event.getClientY(), event.isControlKeyDown(), event.isAltKeyDown(),
event.isShiftKeyDown(), event.isMetaKeyDown());
DomEvent.fireNativeEvent(nativeEvent, cellTable);
}
}, ClickEvent.getType());
Unfortunately the popup cell table is not shown. But I know that the cellTable handles the event.
Regards
Maybe I did not understand your question, but the solution seems to be much simpler.
absolutePanelOver.addDomHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
doSomething();
}
}, ClickEvent.getType());
In your CellTable you invoke the same doSomething() method when a cell is clicked. Now it does not matter whether a cell or an absolute panel is clicked - the same method will be executed.

How to handle back button in windows phone 7?

I have an application, the main page contains few functions. To explain in detail - I have save, color palette button in my main page. When any of these buttons are clicked, save pop up or color palette appears. How to handle back button of the device, when color palette or save pop up is opened. When back button is pressed at these scenario it should just make them invisible and stay on the main page. When nothing is being performed in the main page, then it should come out of the app. I tried to make their visibility collapsed on back button press. But it still is coming out of the application.
Please, guide me in this. Thanks in advance.
Override PhoneApplicationPage.OnBackKeyPress and then set CancelEventArgs.Cancel to true if you want to stop it from actually going back.
protected override void OnBackKeyPress(CancelEventArgs args)
{
if (PanelIsShowing)
{
HidePanel();
args.Cancel = true;
}
}
The back button behaves as is intended by Microsoft.
If you change its behavior you risk your application not being certified for the Marketplace.
If you want the back button to close the popups, turn the popups into pages so the back button navigates back to the main page..
You need to use
protected override void OnBackKeyPress(CancelEventArgs e)
{
if (_popup.IsOpen)
{
_popup.IsOpen= false;
e.Cancel = true;
}
else
{
base.OnBackKeyPress(e);
}
}
That should do the trick.

Resources