A button in an interface consists of text or an icon in form of an image, which results in a corresponding action once the user presses it or touches it.
While working with buttons, we have to keep in mind that primarily we have to work with two classes, that is “Button” and “ImageButton”.
A button responds to a user click with an event, that is why it requires an event handler. This is taken care of by the android:onClick attribute that is associated with the Button element or class. In the demonstration below, it shows how the “sendMessage” activity will get triggered while a user clicks.
Here, the send Message is a function or activity that will be called upon once the user clicks.
|