How to set onclicklistener to image using view binding - android-viewbinding

I am in the process of trying to upgrade an Android app, and i would like to start using view binding.
Currently we have a clickable image resource which is coded like this:
ImageView img = (ImageView) findViewById(R.id.busy);
img.setOnClickListener(v -> startActivity(new Intent(DeviceRegisterActivity.this, InformationRegistrationActivity.class)));
How can i achieve the same using view binding as the below does not work:
private ActionbarViewStorelogonBinding actionbarViewStorelogonBinding;
actionbarViewStorelogonBinding.busy.setOnClickListener(v -> startActivity(new Intent(DeviceRegisterActivity.this, InformationRegistrationActivity.class)));

Related

How to show context menu with preview?

I was wondering how to show a context menu when holding an element then showing a preview with the menu items in SwiftUI? I know how to show context menu items, but not with the preview and the animation.
View video: https://utilities.awesomeplayer.tech/send/f.php?h=35h_YJr5&p=1
I have tried to attach views inside the Context Menu, before the Buttons, but that has not worked.
Any help would be appreciated!
NOTE: The following is only available in iOS 16+ and iPadOS 16+. Earlier versions in second part. From the docs:
This view modifier produces a context menu on macOS, but that platform doesn’t display the preview.
Take a look at the docs here: https://developer.apple.com/documentation/swiftui/gridrow/contextmenu(menuitems:preview:). In iOS 16+, contextMenu accepts a preview argument that is some View. Example:
struct myViewWithPreview: View{
var body: some View{
Text("Hold for contextMenu")
.contextMenu{
//ContextMenu stuff here
//Such as buttons
Button("Example"){}
} preview: {//<-- HERE!!!!
//Here, put any view that you want as a preview. For example, you could put a webview here on a link.
//You could also do an image, such as how they do it on the docs.
Text("Preview!")
}
}
}
If you are using earlier OS versions, you must do this using a custom approach. Take a look at this article. This could also be of use: https://onmyway133.com/posts/how-to-show-context-menu-with-custom-preview-in-swiftui/.

Xamarin forms Master detail Icon

I am trying to add an image next to the hamburger menu in my app. I am using a master detail page and it renders fine in ios and android. I tried using setting the icons for the detail pages. but the icons never showed. How do I achive this. I am looking to add an image similar to the amazon app.
I checked out this app on my phone and it uses a lot of custom constructions that aren't supported by out of the box Xamarin Forms controls. Something like the back arrow next to the hamburger menu is not a standard thing (on iOS at least). Also looking at the actual menu that the hamburger button triggers it becomes clear that its not an out of the box hamburger menu. Theirs pops over the content instead of sliding it out of view as the built-in one does.
More than likely they implemented their own hamburger menu and navigation structure which gave them the freedom to add buttons next to it. If you want to achieve this with out of the box controls you will most likely need custom renderers for each platform to create a replica of this navigation structure.
What is built-in in Xamarin Forms is that you can set the page title to an image instead of text by using the NavigationPage.SetTitleIcon method, which could be used to achieve what you want:
public class MyPage : NavigationPage
{
public MyPage ()
{
var myContentPage = new MyContentPage (Color.White);
this.Push (myContentPage);
var s = "icon.png";
NavigationPage.SetTitleIcon (myContentPage, s);
}
}
Even then, this is limited in functionality. If you want to fiddle with the alignment of the image e.g. you would also need to resort to a custom renderer.

Adding Android views together

Under iOS, I can have something like this
var myButton = new UIButton(new RectangleF(4,4,100,42));
var myTextView = new UITextView
{
Text = "Hello",
Frame = new RectangleF(4,4,42,21)
};
myButton.Add(myTextView);
this allows me to add a UITextView to a UIButton. Very quick and very simple.
Is there something similar that allows me to do something similar on Android?
This is possible if the type of the view is ViewGroup, otherwise no.
You can overlay views, i.e. when they are both inside of a FrameLayout or RelativeLayout.
A short list of ViewGroup type of views I can remember are:
LinearLayout
RelativeLayout
FrameLayout
GridLayout
CardView
Other special views (limited number of nested views)
DrawerLayout
SlidingPaneLayout
List type of views
ListView
RecyclerView
Spinner
In short what you want is not possible with the two views you gave as an example. However, it is entirely possible to change the look of those views to your liking.

how to create iphone like tabs layout in blackberry

How can i create iphone like tabs layout in a blackberry java application for all types of blackberry devices(scrollpad/touch screen). Are there any alternatives to achieve that effect? could you please suggest me in that way?
thanks,
venu
Hi
I had to create tabs in blackberry so for this this i tried a custom way which fulfilled my requirement.May be u can use and customize this idea.
1) create a method addTab() in a class and place say 5 bitmap fields(components) in that.
2) place these components in an horizontal field manager
3) addTab() method must return this manager.
4) create a method result() in that class that must be called whenever the components(Bitmap fields) are clicked.
Now in your main class wherever you want to display the tabs:
1) create object for that class and do
add(obj.addTab());
or u can do :
setStatus(obj.addTab());
depending upon your requirement

Call QFileDialog when trying to edit cell in QTableView

Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate:
Won't have a native dialog.
I'll have to implement my own image preview,
For some reason I can't resize the window cause setGeometry doesn't work, etc etc.
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
In practice, everything that changes the geometry of your widget goes to updateEditorGeometry function. Override it to avoid trying the original one to put your dialog within the cell of the table.
OK so the editor->setGeometry method has to go in the overridden method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?

Resources