Page 55 - 24JAM_Pintar_Pemrograman_Android__1-libre
P. 55

  24 JAM!! Pintar Pemrograman Android













                           (a)                              (b)
              Gambar 6.5. (a) Kombinasi tampilan secara vertivcal dengan
               rata kanan (b) kombinasi tampilan horizontal dengan center

            Penasaran? Yuk, kita latihan..
                1.  Jalankan Enclipse, buat Project baru (gambar 6.3).






                                       Gambar 6. 6
                2.  Isilah parameter seperti berikut


                Project name             RadioButton
                Build Target             Android 2.2
                Application name         Menampilkan Radio Button
                Package name             contoh.RadioButton
                Create Activity          RadioButton
                Min SDK version          8
                3.  Kemudian ketikkan kode berikut ini pada main.xml
                    (Gambar 6.4).

            1:  <?xml version="1.0" encoding="utf-8"?>
            2:      <LinearLayout
            3:  xmlns:android="http://schemas.android.com/apk/res/android"
            4:       android:layout_height="fill_parent"
            5:       android:layout_width="fill_parent"
            6:       android:orientation="vertical">
            7:          <RadioGroup android:padding="5px"
            8:          android:layout_height="wrap_content"
            9:          android:layout_width="wrap_content"
            10:          android:id="@+id/orientation"
            11:          android:orientation="horizontal">
            12:              <RadioButton android:layout_height="wrap_content"
            13:                   android:layout_width="wrap_content"
            14:                   android:id="@+id/horizontal"
            15:                   android:text="Horizontal">
            16:              </RadioButton>
            17:              <RadioButton android:layout_height="wrap_content"
            18:                   android:layout_width="wrap_content"
            19:                   android:id="@+id/vertical"
            20:                   android:text="Vertical">
            21:              </RadioButton>
            22:          </RadioGroup>
                              Dapatkan materi terbaru di                   55
                                       www.omayib.com
   50   51   52   53   54   55   56   57   58   59   60