IT. Expert System.

Android Reference

Button


android.widget

Class Button

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewTreeObserver.OnPreDrawListener
    Direct Known Subclasses:
    CompoundButton


    public class Button
    extends TextView
    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 View.OnClickListener() {
                 public void onClick(View v) {
                     // Perform action on click
                 }
             });
         }
     }

    However, instead of applying an OnClickListener to the button in your activity, you can assign a method to your button in the XML layout, using the android:onClick attribute. For example:

     <Button
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
         android:text="@string/self_destruct"
         android:onClick="selfDestruct" />

    Now, when a user clicks the button, the Android system calls the activity's selfDestruct(View) method. In order for this to work, the method must be public and accept a View as its only parameter. For example:

     public void selfDestruct(View view) {
         // Kabloey
     }

    The View passed into the method is a reference to the widget that was clicked.

    Button style

    Every Button is styled using the system's default button background, which is often different from one device to another and from one version of the platform to another. If you're not satisfied with the default button style and want to customize it to match the design of your application, then you can replace the button's background image with a state list drawable. A state list drawable is a drawable resource defined in XML that changes its image based on the current state of the button. Once you've defined a state list drawable in XML, you can apply it to your Button with the android:background attribute. For more information and an example, see State List Drawable.

    See the Buttons guide.

    XML attributes

    See Button Attributes, TextView Attributes, View Attributes



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 214 / 158748246. Delta: 0.01136 с