I'm working on a Multiple Choice List.
1) How do I check some items in Java?
2) How can I change the graphic for the checkbox?
The Activity:
Using java Syntax Highlighting
- public class Wettschein2Activity extends ListActivity {
- private static final String SYSTEM = "system";
- private static final String[] PARAM = { SYSTEM };
- private SimpleAdapter adapter;
- private List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.wettschein2);
- addItem(list, "alle 1er Kombis (+4 Wetten)");
- addItem(list, "alle 2er Kombis (+9 Wetten)");
- addItem(list, "alle 3er Kombis (+9 Wetten)");
- addItem(list, "alle 4er Kombis (+4 Wetten)");
- addItem(list, "alle 5er Kombis (+1 Wetten)");
- adapter = new SimpleAdapter(this, list, R.layout.systemwette_list_row, PARAM, new int[] { R.id.systemwette });
- setListAdapter(adapter);
- getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
- }
- public void addItem(List<Map<String, Object>> data, String system) {
- Map<String, Object> temp = new HashMap<String, Object>();
- temp.put(SYSTEM, system);
- data.add(temp);
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
The XML for the Activity (shortened):
Using xml Syntax Highlighting
- <ListView android:id="@+id/android:list" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:layout_below="@+id/button_ok"
- android:scrollbarStyle="outsideInset" android:paddingTop="6dip" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
The XML for every line of the list:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/systemwette" android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:checkMark="?android:attr/listChoiceIndicatorMultiple"
- android:paddingLeft="6dip" android:paddingRight="6dip" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Happy New Year,
DaRolla


