Page 53 - 24JAM_Pintar_Pemrograman_Android__1-libre
P. 53
24 JAM!! Pintar Pemrograman Android
3: <string name="hello">Hello World, checkBox!</string>
4: <string name="app_name">Membuat Check Box</string>
5: <string name="checkBox">checkBox ini : Tidak
Dicentang!</string>
6: </resources>
7:
Gambar 6. 3. Letak strings.xml
4. Kemudian ketikkan kode berikut ini pada main.xml
(Gambar 6.4).
8: <?xml version="1.0" encoding="utf-8"?>
9: <CheckBox
xmlns:android="http://schemas.android.com/apk/res/android"
10: android:layout_width="wrap_content"
11: android:id="@+id/check"
12: android:layout_height="wrap_content"
13: android:text="@string/checkBox">
14: </CheckBox>
Gambar 6. 4. Letak main.xml
5. Tuliskan kode checkBox.java seperti berikut.
1: package contoh.checkBox;
2:
3: import android.app.Activity;
4: import android.os.Bundle;
5: import android.widget.CheckBox;
6: import android.widget.CompoundButton;
7: import android.widget.CompoundButton.OnCheckedChangeListener;
8:
9: public class checkBox extends Activity implements
Dapatkan materi terbaru di 53
www.omayib.com