Another new face emerges — @phvismin just made waves with 16 #NFTs 🌊🔥 Huge thanks for bringing such strong energy into the NFToa ecosystem. Moves like this push us all forward 🙌 #eCash $XEC #NFTCommunity #NFTCollection #NFTCollectors #nftprimearts #CryptoMarket #CryptoRecovery pic.twitter.com/T9zkiKPDGj
— NFToa (@nftoa_) September 2, 2025
Checkbox is one of the optional widgets, meaning 2 or more items can be selected simultaneously. Let's try the simplest one first, the scenario is provided with a checkbox that is not yet active, marked with the text "This checkbox: Not checked!". Then if the user clicks, the checkbox changes color to green and the text changes to "This checkbox: checked!". Look at Figure 6.1

Figure 6.1
Before starting, prepare iced tea and snacks next to the computer, so that learning is more enjoyable. Now it's time to start.
1. Run Enclipse, create a new Project.

Figure 6. 2. Create a new project
2. Fill in the parameters as follows
| Project name | MembuatCheckBox |
|------------------|-------------------|
| Build Target | Android 2.2 |
| Application name | Membuat Check Box |
| Package name | contoh.checkBox |
| Create Activity | checkBox |
| Min SDK version | 8 |3. Look at the code in String.xml, see res/values/string.xml (Figure 6.3). Add the code as follows
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, checkBox!</string>
<string name="app name">Membuat Check Box</string>
<string name="checkBox">checkBox ini : Tidak Dicentang!</string>
</resources>
Figure 6. 3. Location of strings.xml
4. Then type the following code in main.xml (Figure 6.4)
<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
android:layout width="wrap content"
android:id="@+id/check"
android:layout height="wrap content"
android:text="@string/checkBox">
</CheckBox>
Figure 6.4. Location of main.xml
5. Write the checkBox.java code as follows
package contoh.checkBox;
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class checkBox extends Activity implements OnCheckedChangeListener {
CheckBox cb;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cb=(CheckBox)findViewById(R.id.check);
cb.setOnCheckedChangeListener(this);
}
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
cb.setText("checkBox ini : Dicentang!");
}
else {
cb.setText("checkBox ini : Tidak Dicentang!");
}
}
}6. If the code is messy, do Format (source > format).
7. Do RUN and see the result. Simple!
Program Explanation
First, take a look at main.xml, here we use a checkbox widget that is given the id "check" (see line 4). The checkbox widget has a text property, the content of which is taken from the string "checkBox" in strings.xml (line 6).
The CheckBox widget has 2 statuses, namely checked and unchecked. By clicking the checkBox, it means we change the status from checked to unchecked or vice versa.
Now let's look at the checkbox.java activity, line 17 is the synchronization between the "cb" object and the CheckBox widget from the main.xml layout, while line 18 is to activate the checkbox widget to function when clicked. This activity implements the OnCheckedChangeListener class, so that the system can recognize whether the checkbox is clicked or not. This activity is read by the onCheckedChanged() method on lines 21-29. This method is responsible for changing the text on the widget when the checkbox is clicked.
