Android listview with radio button
•
Android
I want to change the check box color of the selected item. This is my code:
final ListView listView = (ListView) findViewById(R.id.lvcancelorder);
// Instantiating array adapter to populate the listView
// The layout android.R.layout.simple_list_item_single_choice creates radio button for each listview item
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, countries);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedFromList = (listView.getItemAtPosition(position)).toString();
}});
How can I do this?
resolvent:
It is recommended that you create your own custom adapter from baseadapter or arrayadapter, and only need to change the background color of the root layout view when selecting a project
Use the following link to learn how to create a list view using a check box. See here
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码