| AbsListView |
Base class that can be used to implement virtualized lists of items. |
| AbsSeekBar |
|
| AbsSpinner |
An abstract base class for spinner widgets. |
| AbsoluteLayout |
This class is deprecated.
Use FrameLayout, RelativeLayout
or a custom layout instead.
|
| AbstractInputMethodService |
AbstractInputMethodService provides a abstract base class for input methods. |
| AccountAuthenticatorActivity |
Base class for implementing an Activity that is used to help implement an
AbstractAccountAuthenticator. |
| Activity |
An activity is a single, focused thing that the user can do. |
| ActivityGroup |
This class is deprecated.
Use the new Fragment and FragmentManager APIs
instead; these are also
available on older platforms through the Android compatibility package.
A screen that contains and runs multiple embedded activities.
|
| AdapterView<T extends Adapter> |
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. |
| AlertDialog |
A subclass of Dialog that can display one, two or three buttons. |
| AliasActivity |
Stub activity that launches another activity (and then finishes itself)
based on information in its component's manifest meta-data. |
| AnalogClock |
This widget display an analogic clock with two hands for hours and
minutes. |
| AppWidgetHostView |
Provides the glue to show AppWidget views. |
| AutoCompleteTextView |
An editable text view that shows completion suggestions automatically
while the user is typing. |
| Button |
Represents a push-button widget. |
| CalendarView |
This class is a calendar widget for displaying and selecting dates. |
| CharacterPickerDialog |
Dialog for choosing accented characters related to a base character. |
| CheckBox |
A checkbox is a specific type of two-states button that can be either
checked or unchecked. |
| CheckedTextView |
An extension to TextView that supports the Checkable interface. |
| Chronometer |
Class that implements a simple timer. |
| CompoundButton |
A button with two states, checked and unchecked. |
| DatePicker |
This class is a widget for selecting a date. |
| DatePickerDialog |
A simple dialog containing an DatePicker. |
| DialerFilter |
|
| Dialog |
Base class for Dialogs. |
| DigitalClock |
Like AnalogClock, but digital. |
| EditText |
EditText is a thin veneer over TextView that configures itself
to be editable. |
| ExpandableListActivity |
An activity that displays an expandable list of items by binding to a data
source implementing the ExpandableListAdapter, and exposes event handlers
when the user selects an item. |
| ExpandableListView |
A view that shows items in a vertically scrolling two-level list. |
| ExtractEditText |
Specialization of EditText for showing and interacting with the
extracted text in a full-screen input method. |
| FragmentBreadCrumbs |
Helper class for showing "bread crumbs" representing the fragment
stack in an activity. |
| FrameLayout |
FrameLayout is designed to block out an area on the screen to display
a single item. |
| GLSurfaceView |
An implementation of SurfaceView that uses the dedicated surface for
displaying OpenGL rendering. |
| Gallery |
A view that shows items in a center-locked, horizontally scrolling list. |
| GestureOverlayView |
A transparent overlay for gesture input that can be placed on top of other
widgets or contain other widgets. |
| GridView |
A view that shows items in two-dimensional scrolling grid. |
| HorizontalScrollView |
Layout container for a view hierarchy that can be scrolled by the user,
allowing it to be larger than the physical display. |
| ImageButton |
Displays a button with an image (instead of text) that can be pressed
or clicked by the user. |
| ImageSwitcher |
|
| ImageView |
Displays an arbitrary image, such as an icon. |
| InputMethodService |
InputMethodService provides a standard implementation of an InputMethod,
which final implementations can derive from and customize. |
| KeyboardView |
A view that renders a virtual Keyboard. |
| LauncherActivity |
Displays a list of all activities which can be performed
for a given intent. |
| LinearLayout |
A Layout that arranges its children in a single column or a single row. |
| ListActivity |
An activity that displays a list of items by binding to a data source such as
an array or Cursor, and exposes event handlers when the user selects an item. |
| ListView |
A view that shows items in a vertically scrolling list. |
| MediaController |
A view containing controls for a MediaPlayer. |
| 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. |
| NativeActivity |
Convenience for implementing an activity that will be implemented
purely in native code. |
| NumberPicker |
A widget that enables the user to select a number form a predefined range. |
| PreferenceActivity |
This is the base class for an activity to show a hierarchy of preferences
to the user. |
| ProgressBar |
Visual indicator of progress in some operation. |
| ProgressDialog |
A dialog showing a progress indicator and an optional text message or view. |
| QuickContactBadge |
Widget used to show an image with the standard QuickContact badge
and on-click behavior. |
| RSSurfaceView |
The Surface View for a graphics renderscript (RenderScriptGL) to draw on. |
| RadioButton |
A radio button is a two-states button that can be either checked or
unchecked. |
| RadioGroup |
This class is used to create a multiple-exclusion scope for a set of radio
buttons. |
| RatingBar |
A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in
stars. |
| RelativeLayout |
A Layout where the positions of the children can be described in relation to each other or to the
parent. |
| 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. |
| SeekBar |
A SeekBar is an extension of ProgressBar that adds a draggable thumb. |
| SlidingDrawer |
SlidingDrawer hides content out of the screen and allows the user to drag a handle
to bring the content on screen. |
| Spinner |
A view that displays one child at a time and lets the user pick among them. |
| StackView |
|
| SurfaceView |
Provides a dedicated drawing surface embedded inside of a view hierarchy. |
| TabActivity |
This class is deprecated.
New applications should use Fragments instead of this class;
to continue to run on older devices, you can use the v4 support library
which provides a version of the Fragment API that is compatible down to
DONUT.
For apps developing against HONEYCOMB
or later, tabs are typically presented in the UI using the new
ActionBar.newTab() and
related APIs for placing tabs within their action bar area.
A replacement for TabActivity can also be implemented by directly using
TabHost. You will need to define a layout that correctly uses a TabHost
with a TabWidget as well as an area in which to display your tab content.
A typical example would be:
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
The implementation needs to take over responsibility for switching
the shown content when the user switches between tabs.
import java.util.HashMap;
import com.example.android.supportv4.R;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TabHost;
/**
* This demonstrates how you can implement switching between the tabs of a
* TabHost through fragments. It uses a trick (see the code below) to allow
* the tabs to switch between fragments instead of simple views.
*/
public class FragmentTabs extends FragmentActivity {
TabHost mTabHost;
TabManager mTabManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_tabs);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
mTabManager = new TabManager(this, mTabHost, R.id.realtabcontent);
mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
FragmentStackSupport.CountingFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabManager.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("tab", mTabHost.getCurrentTabTag());
}
/**
* This is a helper class that implements a generic mechanism for
* associating fragments with the tabs in a tab host. It relies on a
* trick. Normally a tab host has a simple API for supplying a View or
* Intent that each tab will show. This is not sufficient for switching
* between fragments. So instead we make the content part of the tab host
* 0dp high (it is not shown) and the TabManager supplies its own dummy
* view to show as the tab content. It listens to changes in tabs, and takes
* care of switch to the correct fragment shown in a separate content area
* whenever the selected tab changes.
*/
public static class TabManager implements TabHost.OnTabChangeListener {
private final FragmentActivity mActivity;
private final TabHost mTabHost;
private final int mContainerId;
private final HashMap<String, TabInfo> mTabs = new HashMap<String, TabInfo>();
TabInfo mLastTab;
static final class TabInfo {
private final String tag;
private final Class<?> clss;
private final Bundle args;
private Fragment fragment;
TabInfo(String _tag, Class<?> _class, Bundle _args) {
tag = _tag;
clss = _class;
args = _args;
}
}
static class DummyTabFactory implements TabHost.TabContentFactory {
private final Context mContext;
public DummyTabFactory(Context context) {
mContext = context;
}
@Override
public View createTabContent(String tag) {
View v = new View(mContext);
v.setMinimumWidth(0);
v.setMinimumHeight(0);
return v;
}
}
public TabManager(FragmentActivity activity, TabHost tabHost, int containerId) {
mActivity = activity;
mTabHost = tabHost;
mContainerId = containerId;
mTabHost.setOnTabChangedListener(this);
}
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
tabSpec.setContent(new DummyTabFactory(mActivity));
String tag = tabSpec.getTag();
TabInfo info = new TabInfo(tag, clss, args);
// Check to see if we already have a fragment for this tab, probably
// from a previously saved state. If so, deactivate it, because our
// initial state is that a tab isn't shown.
info.fragment = mActivity.getSupportFragmentManager().findFragmentByTag(tag);
if (info.fragment != null && !info.fragment.isDetached()) {
FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
ft.detach(info.fragment);
ft.commit();
}
mTabs.put(tag, info);
mTabHost.addTab(tabSpec);
}
@Override
public void onTabChanged(String tabId) {
TabInfo newTab = mTabs.get(tabId);
if (mLastTab != newTab) {
FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
if (mLastTab != null) {
if (mLastTab.fragment != null) {
ft.detach(mLastTab.fragment);
}
}
if (newTab != null) {
if (newTab.fragment == null) {
newTab.fragment = Fragment.instantiate(mActivity,
newTab.clss.getName(), newTab.args);
ft.add(mContainerId, newTab.fragment, newTab.tag);
} else {
ft.attach(newTab.fragment);
}
}
mLastTab = newTab;
ft.commit();
mActivity.getSupportFragmentManager().executePendingTransactions();
}
}
}
}
Also see the
Fragment Tabs Pager sample for an example of using the support library's ViewPager to
allow the user to swipe the content to switch between tabs.
|
| TabHost |
Container for a tabbed window view. |
| TabWidget |
Displays a list of tab labels representing each page in the parent's tab
collection. |
| TableLayout |
A layout that arranges its children into rows and columns. |
| TableRow |
A layout that arranges its children horizontally. |
| TextSwitcher |
Specialized ViewSwitcher that contains
only children of type TextView. |
| TextView |
Displays text to the user and optionally allows them to edit it. |
| TimePicker |
A view for selecting the time of day, in either 24 hour or AM/PM mode. |
| TimePickerDialog |
A dialog that prompts the user for the time of day using a TimePicker. |
| ToggleButton |
Displays checked/unchecked states as a button
with a "light" indicator and by default accompanied with the text "ON" or "OFF". |
| TwoLineListItem |
A view group with two children, intended for use in ListViews. |
| VideoView |
Displays a video file. |
| View |
This class represents the basic building block for user interface components. |
| 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. |
| ViewGroup |
A ViewGroup is a special view that can contain other views
(called children.) The view group is the base class for layouts and views
containers. |
| ViewStub |
A ViewStub is an invisible, zero-sized View that can be used to lazily inflate
layout resources at runtime. |
| ViewSwitcher |
ViewAnimator that switches between two views, and has a factory
from which these views are created. |
| WebView |
A View that displays web pages. |
| ZoomButton |
|
| ZoomControls |
The ZoomControls class displays a simple set of controls used for zooming and
provides callbacks to register for events. |