Android: How to look up a widget (defined in XML layout file) by its id

Android FAQ: How do I look up (find) a widget in my Java code that I’ve defined in an XML layout file?

Solution: When you define your Android widgets in XML and then need to find a widget by its id, the method you need is named findViewById.

For example, you’ll use code like this to look up a widget by its id and create it in your Java code:

Android fragments - How to get an Activity widget

Android Fragments FAQ: How do I access an Activity widget from an Android Fragment?

All you have to do in your Fragment code is use the getActivity method to get a reference to your Activity, and then the usual findViewById method to get a reference to your widget:

Create custom Mac dashboard widgets from web pages with Safari

Mac dashboard widgets FAQ: How can I create a Mac dashboard widget from a web page?

Some time back, I don't remember exactly when, Apple introduced the ability to create Mac dashboard widgets from web pages with their Safari web browser. The process of creating a Mac dashboard widget from a web page is fairly simple, and I thought I'd share the steps in a short tutorial here.

Create a custom Mac dashboard widget from a web page

I just created a Mac dashboard widget from an "aurora borealis" forecast web page, and these are the steps I followed:

A Java tooltip tutorial

Java Swing FAQ: How do I create a Java tooltip (also known as balloon or bubble help text)?

Run Dashboard widgets from your desktop

If you've ever wanted to see your Dashboard widgets outside of the normal Dashboard environment, Amnesty Widgets lets you run your widgets directly on your desktop. It's not free, but if it's something you always wanted, you can download a free trial.


RubySearch dashboard widget

I just found the RubySearch dashboard widget for Mac OS X, and I like it. It offers a simple interface to your local ri/rdoc repository, with hyperlinking between classes, methods, superclasses, etc. It may be a lot better than going back and forth between a Terminal window and typing ri.


Mac Stickies and the Stickies widget

In a previous tip I discussed how to create a Mac sticky note from inside a Cocoa application, but I forgot to mention about how to use stickies as a standalone application.

Fortunately, it's pretty easy. Just open your Applications folder, and click the Stickies application icon. Once the Stickies application is started, just click File, and New Note to create a new sticky note, or press [Command][N].