Android – custom UI with custom attributes

Yes. Short guide: 1. Create an attribute XML Create a new XML file inside /res/values/attrs.xml, with the attribute and it’s type <?xml version=”1.0″ encoding=”UTF-8″?> <resources> <declare-styleable name=”MyCustomElement”> <attr name=”distanceExample” format=”dimension”/> </declare-styleable> </resources> Basically you have to set up one <declare-styleable /> for your view that contains all your custom attributes (here just one). I never … Read more

Composing Swing Components: How do I add the ability to add ActionListeners?

I’d use a JToggelButton, as shown here, or delegate to the contained buttons, as @duffymo suggests. If you really need a custom OnOffSwitchEvent, the standard wiring is outlined in EventListenerList, an instance of which is contained in every JComponent. Addendum: Here’s an example of delegating to a ButtonGroup containing two buttons. The label is decorated … Read more

How to customize a ListField in BlackBerry?

Try something like this: class TaskListField extends ListField implements ListFieldCallback { private Vector rows; private Bitmap p1; private Bitmap p2; private Bitmap p3; public TaskListField() { super(0, ListField.MULTI_SELECT); setRowHeight(80); setEmptyString(“Hooray, no tasks here!”, DrawStyle.HCENTER); setCallback(this); p1 = Bitmap.getBitmapResource(“1.png”); p2 = Bitmap.getBitmapResource(“2.png”); p3 = Bitmap.getBitmapResource(“3.png”); rows = new Vector(); for (int x = 0; x < … Read more

How to make a Scroll Listener for WebView in Android

Something like: public class ObservableWebView extends WebView { private OnScrollChangedCallback mOnScrollChangedCallback; public ObservableWebView(final Context context) { super(context); } public ObservableWebView(final Context context, final AttributeSet attrs) { super(context, attrs); } public ObservableWebView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); } @Override protected void onScrollChanged(final int l, final int t, final int … Read more

How can we do pagination in datagridview in winform

Here’s a simple working example, where a BindingNavigator GUI control uses a BindingSource object to identify page breaks, by setting its DataSource to a custom subclass of IListSource. (Thanks to this answer for the key idea.) When the user clicks the “next page” button, the BindingNavigator fires bindingSource1_CurrentChanged and your code can fetch the desired … Read more

How can I get clickable hyperlinks in AlertDialog from a string resource?

I didn’t really like the currently most popular answer because it significantly changes the formatting of the message in the dialog. Here’s a solution that will linkify your dialog text without otherwise changing the text styling: // Linkify the message final SpannableString s = new SpannableString(msg); // msg should have url to enable clicking Linkify.addLinks(s, … Read more