LAYOUT | Cara Membuat Tabel di Halaman Android Studio | PART 5

Baringin
By -
0

 Pendahuluan

    

    Tabel layout menempatkan turunannya ke dalam kolom dan baris. Artinya untuk membuat sebuah tabel kita harus membuat kolom dan baris dari tabel tersebut. Jumlah kolom dan baris tergantung dari kebutuhan yang di butuhkan oleh pengembang.

    

Membuat Table

    Silahkan buat projek buru di android studio. Masuk ke activity_main.xml. Rubahlah Jenis code di dalamnya seperti berikut:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
tools:context=".MainActivity">

</TableLayout>

    Tambahkan komponen <tableRow ke dalam Layout Table. Perhatikan script berikut:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
tools:context=".MainActivity">
<TableRow>

</TableRow>

<TableRow>

</TableRow>
</TableLayout>

    Terakhir tambahkan komponen TextView seperti berikut ini:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
tools:context=".MainActivity">
<TableRow>
<TextView
android:text="Kolom 1"
android:padding="3dip" />
<TextView
android:text="Kolom 2"
android:padding="3dip" />
</TableRow>

<TableRow>
<TextView
android:text="Kolom 3"
android:padding="3dip" />
<TextView
android:text="Kolom4"
android:padding="3dip" />
</TableRow>
</TableLayout>

   

 Sekarang jalankan program anda



Post a Comment

0Comments

Post a Comment (0)