Sunday, January 1, 2012

Android : Button

 in /res/layout/main.xml.
add below

<Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/name"
        android:onClick="buttonName" />

android:text ->  change text inside the button
open res/values/strings.xml
add this : 
 <string name="name>some text here</string>

android:onClick - > add event when button is click ( android 1.6 above)
to add the event -> open java file in src
add this as method name in the class
public void buttonName (View view) {
 // add some action

need to import android.view.View
method name = = value in android:onClick

No comments:

Post a Comment