page.title=Buttons page.tags=button,imagebutton @jd:body

In this document

  1. Responding to Click Events
    1. Using an OnClickListener
  2. Styling Your Button
    1. Borderless button
    2. Custom background

Key classes

  1. {@link android.widget.Button}
  2. {@link android.widget.ImageButton}

A button consists of text or an icon (or both text and an icon) that communicates what action occurs when the user touches it.

Depending on whether you want a button with text, an icon, or both, you can create the button in your layout in three ways:

Responding to Click Events

When the user clicks a button, the {@link android.widget.Button} object receives an on-click event.

To define the click event handler for a button, add the {@link android.R.attr#onClick android:onClick} attribute to the {@code