English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.Button

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.widget.TextView
android.widget.Button

Button represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action. A typical use of a push-button in an activity would be the following:

 public class MyActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);

         setContentView(R.layout.content_layout_id);

         final Button button = (Button) findViewById(R.id.button_id);
         button.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
                 // Perform action on click
             }
         });
     }
 }
 

XML attributes

See Button Attributes, TextView Attributes, View Attributes

Known Direct Subclasses
Known Indirect Subclasses

Summary

XML Attributes inherited from class android.widget.TextView
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.View
Fields inherited from class android.view.View

Public Constructors

          Button(Context context)
          Button(Context context, AttributeSet attrs, Map inflateParams)
          Button(Context context, AttributeSet attrs, Map inflateParams, int defStyle)
Methods inherited from class android.widget.TextView