Supported Widget Views and Layouts

Because of security and performance considerations there are several restrictions on the layouts and Views available to you when you're constructing your widget UI.

In general, the following Views are unavailable for App Widget layouts and will result in a null pointer error (NPE) if used:

V All custom Views

V Descendents of the allowed Views

V EditText

Currently, the layouts available are limited to:

V FrameLayout

V LinearLayout

V RelativeLayout

The Views they contain are restricted to:

V

AnalogClock

V

Button

V

Chronometer

V

ImageButton

V

ImageView

V

ProgressBar

V

TextView

The Text Views and Image Views are particularly useful. Later in this chapter you'll see how to use the Image View in conjunction with the SelectionStateDrawable resource to create interactive widgets with little or no code.

Listing 10-1 shows a sample layout resource used to define the UI of an App Widget.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment