I would like to develop a ListView with Checkbox. However, an unknown character string is displayed.[1]
What is this string? Why is this character string displayed?
Main:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView lvCB = findViewById(R.id.lvCB);
List<Object> cbList = new ArrayList<>();
cbList.add(MainActivity.this);
ArrayAdapter<Object> adapter = new ArrayAdapter<>(MainActivity.this, R.layout.row, cbList);
lvCB.setAdapter(adapter);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lvCB"
android:layout_width="match_parent"
android:layout_height="match_parent" />
row.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cb01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""/>
Aucun commentaire:
Enregistrer un commentaire