I'm looking for a workaround for using RadListView's scrollPosition property in Android, as it is available only in iOS.
Trying to look for some properties in android's RecyclerView widget docs
Any insights?
Check this answer: https://stackoverflow.com/a/38248034
Since RadListView code is closed source, you'd probably have to inspect it to check what classes it's using underneath. As it extends RecyclerView, you could try radlistview.android.getLayoutManager(), find out which class it is and call the equivalent method to get the view id (each LayoutManager has it's own findFirst...() method).
Related
I am working on a Xamarin project that includes a build for GTK. I am attempting to create a custom renderer for many of the Controls, but am having trouble finding, accessing and changing the properties for the control. For example, I would like to replace the "magnifying glass" icon for the SearchBar control with something more similar to the default icon on the Android platform.
I've created the custom renderer:
namespace MyProject.GTK.CustomRenderers
{
public class CustomSearchBarRenderer : Xamarin.Forms.Platform.GTK.Renderers.SearchBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
{
base.OnElementChanged(e);
var searchBar = Control;
// How do I replace the image?
}
}
}
but from there I am at a loss as there are practically no resources on custom renderers for GTK. I've tried looking at the GTK.Renderers.SearchBarRenderer to see if the class its derived from contains any useful properties or methods, as well as trying to find something meaningful in the GTK documentation and the repository for the Xamarin.Forms.GTK package, to no avail. I'm just not really sure how to understand the inner workings of the controls in this build so I can't figure out what I should even be looking for. Any pointers or resources for this or any GTK specific custom renderer work would be much appreciated.
You can check Xamarin Forms GTK
SearchBar is implmented by the use of element called SearchEntry which uses ImageButton and the icon is set by below code
_searchButton.ImageWidget.Pixbuf = RenderIcon("gtk-find", IconSize.SmallToolbar, null); // Search icon
Refer
SearchEntry.GTK
SearchBar.GTK
This should help you begin modifying, if you can get access to SearchEntry in your custom renderer you can change icon, otherwise you will have to create your own search bar, which takes lot of effort.
It is very easy to handle event with FLTK Button (Fl_Button). This is done using callback() method inherited from Widget class. But I tried using with other widgets like Fl_Box (widget that displays image or text) but not worked and there is no compile error because Fl_Box is also subclass of Widget so something like flbox_pointer->callback(mycallback) is valid.
In Java you can use mouse event on any component like JButton, JPanel, JLabel etc, but in C++ FLTK seems very difficult.
So, somebody can help me with piece of code to do this. I have already checked their docs but all examples of callbacks deal with Fl_Button, not other Widgets. The method that looks like it works is virtual int handle(int) but it forces to create class, extending then overriding it (something that I don't like for now!).
I need to obtain the native Android StackView control from Xamarin.Forms.StackLayout instance. Here is some pseudo-code to explain the problem:
void ProcessMySL(Xamarin.Forms.StackLayout sl) {
var renderer =
Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer(sl);
...
}
When I examine renderer object, it is of type Xamarin.Forms.Platform.Android.VisualElementRenderer. However, it does not have any property such as Control to get me the native StackView object.
I am wondering how can I obtain the native view. Regards.
Xamarin.Forms.Platform.Android.VisualElementRenderer. However, it does not have any property such as Control to get me the native StackView object.
Refering to the official document of Renderer:Renderer Base Classes and Native Control. StackLayout is using ViewRenderer and is thus rendered into a View object, not a StackView.
Besides, using Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer(sl) only return a DefaultRenderer, which doesn't expose the Control property. So, please create a custom renderer instead.
It appears Xamarin.Forms.StackLayout in not rendered as Android's StackView control but a more generic ViewGroup object. To get the Android native view, the following code would work:
var renderer = RenderFactory.GetRenderer(stackLayout);
Android.Views.View view = renderer.ViewGroup;
...
I searched all around stackoverflow and other websites but can not find a very simple thing. I suppose, it could have been answered already, then, could anyone just link the answer?
I am interested in what "custom class" in Xcode is in attributes inspector and how it works, what it actually does. I know very well how to make things work, but I do not have understanding of what I am doing.
To clarify. We can create a UITableViewCell class with, say, name cellClass, then we create .xib with the same name. Inside of .xib we drag UITableViewCell on the canvas and select its custom class - the name of the UITableViewCell class created before - in attributes inspector. So, what is this custom class in the attributes inspector is not clear for me. The example is very specific though, since we are using custom class for other things.
Thanks.
I think you are talking about the possibility to change the class of a predefined object in a .xib. If you insert a button to the interface, its class is NSButton, this to say that you instanciate an NSButton. But, you may have the need to extends NSButton into a MyButton class with specific added properties, methods, etc. If you want to instantiate it through .xib then you just have to drag'n'drop an NSButton and change its class to MyButton in the Identity inspector tab, Custom class form.
It is not very frequent to use NSButton this way, but much more common for some other objects, NSView for example (read Apple docs on subclassing NSView)
Are you talking about (Extensions, categories).
Please refer to this link:
Extensions
If you having issues in creating new subclases in xcode 7.1 then please click on:
File->New->Cocoa Touch Class-> Classname and select subclass of, it will works and you will be able to assign classes to uiviewcontrollers as well.
How do I add custom objects to the custom object library in xcode?
I created a class myObject and I want this new object to appear in my object library list for use with IB.
This is not a direct answer, but if your custom object is a subclass of something else, e.g. NSObject or UIView, etc, then you can simply select the parent object and then change the identity to your subclass with the attributes window.
If you want a direct answer, then read this post: How do you display custom UIViews in InterfaceBuilder? for instructions to create a plug-in for Interface Builder that uses your custom class.
Xcode 4 doesn't support IB plug-ins anymore. You're out of luck.
(This is a direct quote from a comment of one of the answers to How do you display custom UIViews in InterfaceBuilder?)