Android Button State

Create and copy the code below in UserInterfaceActivity class


package chapter.seven;

import android.app.Activity;
import android.os.Bundle;

public class UserInterface extends Activity {
    /** Called when the activity is first created. */
    @Override
    //seee pg 117-120
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}


Copy the code below in main.xml file


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<!-- creating image button see pg 120 -->
    <ImageButton
        android:id="@+id/button_one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/button1s"
        android:paddingTop="5px"
         />
</LinearLayout>

Copy the code below and put all the images in res/drawable folder


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<!-- creating image button see pg 120 -->
    <ImageButton
        android:id="@+id/button_one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/button1s"
        android:paddingTop="5px"
         />
</LinearLayout>


Screen shot of the output

source file can be downloaded from below link
click here



No comments:

Post a Comment