Page 30 - 24JAM_Pintar_Pemrograman_Android__1-libre
P. 30

  24 JAM!! Pintar Pemrograman Android
               1:  <?xml version="1.0" encoding="utf-8"?>
               2:  <RelativeLayout
                   xmlns:android="http://schemas.android.com/apk/res/android
                   "
               3:      android:layout_width="fill_parent"
               4:      android:layout_height="fill_parent"
                   android:gravity="top">
               5:      <TextView
               6:          android:id="@+id/label"
               7:          android:layout_width="fill_parent"
               8:          android:layout_height="wrap_content"
               9:          android:text="Type here:"/>
               10:      <EditText
               11:          android:id="@+id/entry"
               12:          android:layout_width="fill_parent"
               13:          android:layout_height="wrap_content"
               14:          android:layout_below="@id/label"/>
               15:      <Button
               16:          android:id="@+id/ok"
               17:          android:layout_width="wrap_content"
               18:          android:layout_height="wrap_content"
               19:          android:layout_below="@id/entry"
               20:          android:layout_alignParentRight="true"
               21:          android:layout_marginLeft="10dip"
               22:          android:text="OK" />
               23:      <Button
               24:          android:layout_alignTop="@id/ok"
               25:          android:text="Cancel"
               26:          android:layout_height="wrap_content"
               27:          android:layout_width="wrap_content"
               28:          android:layout_toLeftOf="@+id/ok"
               29:          android:layout_below="@+id/entry"/>
               30:  </RelativeLayout>

                2.  Pastikan  script  pada  RelativeLayoutSederhana.java
                    seperti dibawah ini.

               1:  package contoh.layoutRelatif;
               2:
               3:  import android.app.Activity;
               4:  import android.os.Bundle;
               5:
               6:  public class RelativeLayoutSederhana extends Activity {
               7:      /** Called when the activity is first created. */
               8:      @Override
               9:      public void onCreate(Bundle savedInstanceState) {
               10:          super.onCreate(savedInstanceState);
               11:          setContentView(R.layout.main);
               12:      }
               13:  }

                3.  Lakukan  Run  dengan  shortcut  CTRL+F11  atau  klik
                    kanan package > run as > android Project.
                4.  Lihat hasilnya seperti Gambar 3.5

                              Dapatkan materi terbaru di                   30
                                       www.omayib.com
   25   26   27   28   29   30   31   32   33   34   35