Android.Widget Namespace
The widget package contains (mostly visual) UI elements to use
on your Application screen.
Remarks
The widget package contains (mostly visual) UI elements to use on your Application screen. You can also design your own.
To create your own widget, extend View or a subclass. To use your widget in layout XML, there are two additional files for you to create. Here is a list of files you'll need to create to implement a custom widget:
- Java implementation file - This is the file that implements the behavior of the widget. If you can instantiate the object from layout XML, you will also have to code a constructor that retrieves all the attribute values from the layout XML file.
- XML definition file - An XML file in res/values/ that defines the XML element used to instantiate your widget, and the attributes that it supports. Other applications will use this element and attributes in their in another in their layout XML.
- Layout XML [optional]- An optional XML file inside res/layout/ that describes the layout of your widget. You could also do this in code in your Java file.
ApiDemos sample application has an example of creating a custom layout XML tag, LabelView. See the following files that demonstrate implementing and using a custom widget:
- LabelView.java - The implementation file
- res/values/attrs.xml - Definition file
- res/layout/custom_view_1.xml - Layout file
Classes
| Type | Reason |
|---|---|
| AbsListView | Base class that can be used to implement virtualized lists of items. |
| AbsListView+IMultiChoiceModeListener | A MultiChoiceModeListener receives events for AbsListViewChoiceMode.MultipleModal. |
| IOnScrollListener | Interface definition for a callback to be invoked when the list or grid has been scrolled. |
| IRecyclerListener | A RecyclerListener is used to receive a notification whenever a View is placed inside the RecycleBin's scrap heap. |
| ISelectionBoundsAdjuster | The top-level view of a list item can implement this interface to allow itself to modify the bounds of the selection shown for that item. |
| LayoutParams | AbsListView extends LayoutParams to provide a place to hold the view type. |
| RecyclerEventArgs | Provides data for the AbsListView.Recycler event. |
| ScrollEventArgs | Provides data for the AbsListView.Scroll event. |
| ScrollStateChangedEventArgs | Provides data for the AbsListView.ScrollStateChanged event. |
| AbsListViewChoiceMode | Enumerates values returned by several methods of AbsListViewChoiceMode. |
| AbsoluteLayout | A layout that lets you specify exact locations (x/y coordinates) of its children. |
| LayoutParams | Per-child layout information associated with AbsoluteLayout. |
| AbsSeekBar | [Android Documentation] |
| AbsSpinner | An abstract base class for spinner widgets. |
| ActionMenuView | ActionMenuView is a presentation of a series of menu options as a View. |
| IOnMenuItemClickListener | |
| LayoutParams | |
| MenuItemClickEventArgs | Provides data for the ActionMenuView.MenuItemClick event. |
| Adapter | An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. |
| AdapterConsts | |
| AdapterView | An AdapterView is a view whose children are determined by an Adapter. |
| AdapterContextMenuInfo | Extra menu information provided to the IOnCreateContextMenuListener.OnCreateContextMenu(IContextMenu,View,View) callback when a context menu is brought up for this AdapterView. |
| IOnItemClickListener | Interface definition for a callback to be invoked when an item in this AdapterView has been clicked. |
| IOnItemLongClickListener | Interface definition for a callback to be invoked when an item in this view has been clicked and held. |
| IOnItemSelectedListener | Interface definition for a callback to be invoked when an item in this view has been selected. |
| ItemClickEventArgs | Provides data for the AdapterView.ItemClick, AutoCompleteTextView.ItemClick, and ListPopupWindow.ItemClick events. |
| ItemLongClickEventArgs | Provides data for the AdapterView.ItemLongClick event. |
| ItemSelectedEventArgs | Provides data for the AlertDialog+Builder.ItemSelected, AdapterView.ItemSelected, AutoCompleteTextView.ItemSelected, and ListPopupWindow.ItemSelected events. |
| NothingSelectedEventArgs | Provides data for the AlertDialog+Builder.NothingSelected, AdapterView.NothingSelected, AutoCompleteTextView.NothingSelected, and ListPopupWindow.NothingSelected events. |
| AdapterView`1 | An AdapterView is a view whose children are determined by an Adapter. |
| AdapterViewAnimator | Base class for a AdapterView that will perform animations when switching between its views. |
| AdapterViewFlipper | Simple ViewAnimator that will animate between two or more views that have been added to it. |
| AlphabetIndexer | A helper class for adapters that implement the SectionIndexer interface. |
| AnalogClock | This widget display an analogic clock with two hands for hours and minutes. |
| ArrayAdapter | A concrete BaseAdapter that is backed by an array of arbitrary objects. |
| ArrayAdapter`1 | A concrete BaseAdapter that is backed by an array of arbitrary objects. |
| AutoCompleteTextView |
java Example public class CountriesActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private static final String[] COUNTRIES = new String[] {
"Belgium", "France", "Italy", "Germany", "Spain"
};
} |
| IOnDismissListener | Listener to respond to the AutoCompleteTextView's completion list being dismissed. |
| IValidator | This interface is used to make sure that the text entered in this TextView complies to a certain format. |
| AutoCompleteTextViewIValidatorExtensions | |
| BaseAdapter | Common base class of common implementation for an Adapter that can be used in both ListView (by implementing the specialized IListAdapter interface) and Spinner (by implementing the specialized ISpinnerAdapter interface). |
| InterfaceConsts | |
| BaseAdapter`1 | Common base class of common implementation for an Adapter that can be used in both ListView (by implementing the specialized IListAdapter interface) and Spinner (by implementing the specialized ISpinnerAdapter interface). |
| BaseExpandableListAdapter | Base class for a IExpandableListAdapter used to provide data and Views from some data to an expandable list view. |
| Button | Represents a push-button widget. |
| CalendarView | This class is a calendar widget for displaying and selecting dates. |
| DateChangeEventArgs | Provides data for the CalendarView.DateChange event. |
| IOnDateChangeListener | The callback used to indicate the user changes the date. |
| CheckBox |
java Example public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.content_layout_id);
final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
if (checkBox.isChecked()) {
checkBox.setChecked(false);
}
}
} |
| CheckedTextView | An extension to TextView that supports the ICheckable interface. |
| ChoiceMode | Enumerates values returned by several types. |
| Chronometer | Class that implements a simple timer. |
| IOnChronometerTickListener | A callback that notifies when the chronometer has incremented on its own. |
| CompoundButton | |
| CheckedChangeEventArgs | Provides data for the CompoundButton.CheckedChange event. |
| IOnCheckedChangeListener | Interface definition for a callback to be invoked when the checked state of a compound button changed. |
| CursorAdapter | Adapter that exposes data from a ICursor to a ListView widget. |
| CursorAdapterFlags | Enumerates values returned by the CursorAdapterFlags.AutoRequery, CursorAdapterFlags.None, and CursorAdapterFlags.RegisterContentObserver members and taken as a parameter of the Android.Widget.CursorAdapter..ctor, Android.Widget.ResourceCursorAdapter..ctor, and Android.Widget.SimpleCursorAdapter..ctor members. |
| CursorTreeAdapter | An adapter that exposes data from a series of ICursors to an ExpandableListView widget. |
| DatePicker | This class is a widget for selecting a date. |
| DateChangedEventArgs | |
| IOnDateChangedListener | The callback used to indicate the user changes\d the date. |
| DialerFilter | [Android Documentation] |
| DialerMode | Enumerates values returned by several types. |
| DigitalClock | Like AnalogClock, but digital. |
| EdgeEffect | This class performs the graphical effect used at the edges of scrollable widgets when the user scrolls beyond the content bounds in 2D space. |
| EditText | EditText is a thin veneer over TextView that configures itself to be editable. |
| ExpandableListView | A view that shows items in a vertically scrolling two-level list. |
| ChildClickEventArgs | Provides data for the ExpandableListView.ChildClick event. |
| ExpandableListContextMenuInfo | Extra menu information specific to an ExpandableListView provided to the IOnCreateContextMenuListener.OnCreateContextMenu(IContextMenu,View,View) callback when a context menu is brought up for this AdapterView. |
| GroupClickEventArgs | Provides data for the ExpandableListView.GroupClick event. |
| GroupCollapseEventArgs | Provides data for the ExpandableListView.GroupCollapse event. |
| GroupExpandEventArgs | Provides data for the ExpandableListView.GroupExpand event. |
| IOnChildClickListener | Interface definition for a callback to be invoked when a child in this expandable list has been clicked. |
| IOnGroupClickListener | Interface definition for a callback to be invoked when a group in this expandable list has been clicked. |
| IOnGroupCollapseListener | Used for being notified when a group is collapsed |
| IOnGroupExpandListener | Used for being notified when a group is expanded |
| Filter | |
| FilterEventArgs | |
| FilterResults | |
| IFilterListener | |
| FrameLayout | FrameLayout is designed to block out an area on the screen to display a single item. |
| LayoutParams | Per-child layout information for layouts that support margins. |
| Gallery | A view that shows items in a center-locked, horizontally scrolling list. |
| LayoutParams | Gallery extends LayoutParams to provide a place to hold current Transformation information along with previous position/transformation info. |
| GridAlign | Enumerates values returned by several types. |
| GridLayout | A layout that places its children in a rectangular grid. |
| Alignment | Alignments specify where a view should be placed within a cell group and what size it should be. |
| LayoutParams | Layout information associated with each of the children of a GridLayout. |
| Spec | A Spec defines the horizontal or vertical characteristics of a group of cells. |
| GridOrientation | Enumerates values returned by several types. |
| GridView | A view that shows items in two-dimensional scrolling grid. |
| HeaderViewListAdapter | ListAdapter used when a ListView has header views. |
| InterfaceConsts | |
| HorizontalScrollView | Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. |
| IAdapter | An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. |
| IAdvanceable | This interface can be implemented by any collection-type view which has a notion of progressing through its set of children. |
| ICheckable | Defines an extension for views that make them checkable. |
| IExpandableListAdapter | An adapter that links a ExpandableListView with the underlying data. |
| IFilterable | |
| IFilterQueryProvider | This class can be used by external clients of CursorAdapter and CursorTreeAdapter to define how the content of the adapter should be filtered. |
| IFilterQueryProviderExtensions | |
| IHeterogeneousExpandableList | Additional methods that when implemented make an IExpandableListAdapter take advantage of the Adapter view type mechanism. |
| IListAdapter | Extended Adapter that is the bridge between a ListView and the data that backs the list. |
| ImageButton |
xml Example <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector> |
| ImageSwitcher | [Android Documentation] |
| ImageView | Displays an arbitrary image, such as an icon. |
| ScaleType | Options for scaling the bounds of an image to the bounds of this view. |
| InputMethod | Enumerates values returned by several types. |
| ISectionIndexer | Interface that may implemented on Adapters to enable fast scrolling between sections of an AbsListView. |
| ISpinnerAdapter | Extended Adapter that is the bridge between a Spinner and its data. |
| ItemEventArgs | |
| ItemViewType | Enumerates values returned by the ItemViewType.HeaderOrFooter, and ItemViewType.Ignore members. |
| IWrapperListAdapter | List adapter that wraps another list adapter. |
| LayoutRules | Enumerates values returned by several methods of LayoutRules and taken as a parameter of the RelativeLayout+LayoutParams.AddRule, RelativeLayout+LayoutParams.AddRule, and RelativeLayout+LayoutParams.RemoveRule members. |
| LinearLayout | A Layout that arranges its children in a single column or a single row. |
| LayoutParams | Per-child layout information associated with ViewLinearLayout. |
| ListPopupWindow | A ListPopupWindow anchors itself to a host view and displays a list of choices. |
| ListPopupWindowInputMethodMode | Enumerates values returned by several types. |
| ListView | A view that shows items in a vertically scrolling list. |
| FixedViewInfo | A class that represents a fixed view in a list, for example a header at the top or a footer at the bottom. |
| MediaController | A view containing controls for a MediaPlayer. |
| IMediaPlayerControl | |
| MultiAutoCompleteTextView | An editable text view, extending AutoCompleteTextView, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing. |
| CommaTokenizer | This simple Tokenizer can be used for lists where the items are separated by a comma and one or more spaces. |
| ITokenizer | |
| MultiAutoCompleteTextViewITokenizerExtensions | |
| NumberPicker | A widget that enables the user to select a number from a predefined range. |
| IFormatter | Interface used to format current value into a string for presentation. |
| IOnScrollListener | Interface to listen for the picker scroll state. |
| IOnValueChangeListener | Interface to listen for changes of the current value. |
| ScrollEventArgs | Provides data for the NumberPicker.Scroll event. |
| ValueChangeEventArgs | Provides data for the NumberPicker.ValueChanged event. |
| NumberPickerScrollState | Enumerates values returned by several types and taken as a parameter of the NumberPicker+IOnScrollListener.OnScrollStateChange, and Android.Widget.NumberPicker.ScrollEventArgs..ctor members. |
| Orientation | Enumerates values returned by the LinearLayout.Orientation, Orientation.Horizontal, and Orientation.Vertical members. |
| OverScroller | This class encapsulates scrolling with the ability to overshoot the bounds of a scrolling operation. |
| PackedPositionType | Enumerates values returned by several types. |
| PopupMenu | A PopupMenu displays a Menu in a modal popup window anchored to a View. |
| DismissEventArgs | Provides data for the PopupMenu.DismissEvent event. |
| IOnDismissListener | Callback interface used to notify the application that the menu has closed. |
| IOnMenuItemClickListener | Interface responsible for receiving menu item click events if the items themselves do not have individual item click listeners. |
| MenuItemClickEventArgs | Provides data for the PopupMenu.MenuItemClick event. |
| PopupWindow | |
| IOnDismissListener | Listener that is called when this popup window is dismissed. |
| PositionPrompt | Enumerates values returned by several types. |
| ProgressBar | |
| QuickContactBadge | Widget used to show an image with the standard QuickContact badge and on-click behavior. |
| RadioButton | |
| RadioGroup | |
| CheckedChangeEventArgs | Provides data for the RadioGroup.CheckedChange event. |
| IOnCheckedChangeListener | |
| LayoutParams | |
| RatingBar | A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. |
| IOnRatingBarChangeListener | A callback that notifies clients when the rating has been changed. |
| RatingBarChangeEventArgs | Provides data for the RatingBar.RatingBarChange event. |
| RelativeLayout | A Layout where the positions of the children can be described in relation to each other or to the parent. |
| LayoutParams | Per-child layout information associated with RelativeLayout. |
| RemoteViews | A class that describes a view hierarchy that can be displayed in another process. |
| ActionException | Exception to send when something goes wrong executing an action |
| InterfaceConsts | |
| RemoteView | This annotation indicates that a subclass of View is alllowed to be used with the RemoteViews mechanism. |
| RemoteViewsService | The service to be connected to for a remote adapter to request RemoteViews. |
| IRemoteViewsFactory | An interface for an adapter between a remote collection view (ListView, GridView, etc) and the underlying data for that view. |
| ResourceCursorAdapter | An easy adapter that creates views defined in an XML file. |
| ResourceCursorTreeAdapter | A fairly simple ExpandableListAdapter that creates views defined in an XML file. |
| Scroller |
java Example private Scroller mScroller = new Scroller(context);
...
public void zoomIn() {
// Revert any animation currently in progress
mScroller.forceFinished(true);
// Start scrolling by providing a starting point and
// the distance to travel
mScroller.startScroll(0, 0, 100, 0);
// Invalidate to request a redraw
invalidate();
}java Example if (mScroller.computeScrollOffset()) {
// Get current x and y positions
int currX = mScroller.getCurrX();
int currY = mScroller.getCurrY();
...
} |
| ScrollState | Enumerates values returned by several types and taken as a parameter of the AbsListView+IOnScrollListener.OnScrollStateChanged, and Android.Widget.AbsListView.ScrollStateChangedEventArgs..ctor members. |
| ScrollView | Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. |
| SearchView | A widget that provides a user interface for the user to enter a search query and submit a request to a search provider. |
| CloseEventArgs | Provides data for the SearchView.Close event. |
| IOnCloseListener | |
| IOnQueryTextListener | Callbacks for changes to the query text. |
| IOnSuggestionListener | Callback interface for selection events on suggestions. |
| QueryTextChangeEventArgs | Provides data for the SearchView.QueryTextChange event. |
| QueryTextSubmitEventArgs | Provides data for the SearchView.QueryTextSubmit event. |
| SuggestionClickEventArgs | Provides data for the SearchView.SuggestionClick event. |
| SuggestionSelectEventArgs | Provides data for the SearchView.SuggestionSelect event. |
| SeekBar | A SeekBar is an extension of ProgressBar that adds a draggable thumb. |
| IOnSeekBarChangeListener | A callback that notifies clients when the progress level has been changed. |
| ProgressChangedEventArgs | Provides data for the SeekBar.ProgressChanged event. |
| StartTrackingTouchEventArgs | Provides data for the SeekBar.StartTrackingTouch event. |
| StopTrackingTouchEventArgs | Provides data for the SeekBar.StopTrackingTouch event. |
| ShareActionProvider | This is a provider for a share action. |
| IOnShareTargetSelectedListener | Listener for the event of selecting a share target. |
| ShareTargetSelectedEventArgs | Provides data for the ShareActionProvider.ShareTargetSelected event. |
| ShowDividers | Enumerates values returned by several types. |
| SimpleAdapter | An easy adapter to map static data to views defined in an XML file. |
| IViewBinder | This class can be used by external clients of SimpleAdapter to bind values to views. |
| SimpleCursorAdapter | An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. |
| ICursorToStringConverter | This class can be used by external clients of SimpleCursorAdapter to define how the Cursor should be converted to a String. |
| IViewBinder | This class can be used by external clients of SimpleCursorAdapter to bind values fom the Cursor to views. |
| SimpleCursorAdapterICursorToStringConverterExtensions | |
| SimpleCursorTreeAdapter | An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file. |
| IViewBinder | This class can be used by external clients of SimpleCursorTreeAdapter to bind values from the Cursor to views. |
| SimpleExpandableListAdapter | An easy adapter to map static data to group and child views defined in an XML file. |
| SlidingDrawer | SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen. |
| IOnDrawerCloseListener | Callback invoked when the drawer is closed. |
| IOnDrawerOpenListener | Callback invoked when the drawer is opened. |
| IOnDrawerScrollListener | Callback invoked when the drawer is scrolled. |
| SlidingDrawerOrientation | Enumerates values returned by several types. |
| Space | Space is a lightweight View subclass that may be used to create gaps between components in general purpose layouts. |
| Spinner | A view that displays one child at a time and lets the user pick among them. |
| SpinnerMode | Enumerates values returned by the SpinnerMode.Dialog, and SpinnerMode.Dropdown members and taken as a parameter of the Android.Widget.Spinner..ctor, Android.Widget.Spinner..ctor, and Android.Widget.Spinner..ctor members. |
| StackView | [Android Documentation] |
| StretchMode | Enumerates values returned by several types. |
| Switch | A Switch is a two-state toggle switch widget that can select between two options. |
| TabHost | Container for a tabbed window view. |
| IOnTabChangeListener | Interface definition for a callback to be invoked when tab changed |
| ITabContentFactory | Makes the content of a tab when it is selected. |
| TabChangeEventArgs | Provides data for the TabHost.TabChanged event. |
| TabSpec | A tab has a tab indicator, content, and a tag that is used to keep track of it. |
| TableLayout | |
| LayoutParams | |
| TableRow | |
| LayoutParams | |
| TabWidget | Displays a list of tab labels representing each page in the parent's tab collection. |
| TextClock |
|
| TextSwitcher | Specialized ViewSwitcher that contains only children of type TextView. |
| TextView | Displays text to the user and optionally allows them to edit it. |
| BufferType | |
| EditorActionEventArgs | Provides data for the TextView.EditorAction event. |
| IOnEditorActionListener | Interface definition for a callback to be invoked when an action is performed on the editor. |
| SavedState | User interface state that is stored by TextView for implementing View.OnSaveInstanceState. |
| TimePicker | A view for selecting the time of day, in either 24 hour or AM/PM mode. |
| IOnTimeChangedListener | The callback interface used to indicate the time has been adjusted. |
| TimeChangedEventArgs | Provides data for the TimePicker.TimeChanged event. |
| Toast | A toast is a view containing a quick little message for the user. |
| ToastLength | Enumerates values returned by the Toast.Duration, ToastLength.Long, and ToastLength.Short members and taken as a parameter of the Toast.MakeText, Toast.MakeText, and Toast.MakeText members. |
| ToggleButton | Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF". |
| Toolbar | A standard toolbar for use within application content. |
| IOnMenuItemClickListener | |
| LayoutParams | |
| MenuItemClickEventArgs | Provides data for the Toolbar.MenuItemClick event. |
| TranscriptMode | Enumerates values returned by several types. |
| TwoLineListItem | |
| VideoView | Displays a video file. |
| ViewAnimator | Base class for a FrameLayout container that will perform animations when switching between its views. |
| ViewFlipper | Simple ViewAnimator that will animate between two or more views that have been added to it. |
| ViewSwitcher | ViewAnimator that switches between two views, and has a factory from which these views are created. |
| IViewFactory | Creates views in a ViewSwitcher. |
| ZoomButton | [Android Documentation] |
| ZoomButtonsController | The ZoomButtonsController handles showing and hiding the zoom controls and positioning it relative to an owner view. |
| IOnZoomListener | Interface that will be called when the user performs an interaction that triggers some action, for example zooming. |
| VisibilityChangedEventArgs | Provides data for the ZoomButtonsController.VisibilityChanged event. |
| ZoomEventArgs | Provides data for the ZoomButtonsController.Zoom event. |
| ZoomControls | The ZoomControls class displays a simple set of controls used for zooming and provides callbacks to register for events. |

