Click here to Skip to main content
12,758,918 members (30,327 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java Mobile Android
I was following the ListView official tutorial - [url][/url], because I get the entries dinamically through a webservice.

Problem is, I want to place checkboxes at it. I have this

(aux (String [] aux) is previously and correctly fullfilled before this)
//setListAdapter(new ArrayAdapter<String>(this, R.layout.lista, aux));
        setListAdapter(new ArrayAdapter<CheckBox>(this,R.layout.row, convertToListItem(aux)));

        //ListView lv = getListView();

And I think the problem is on my row.xml

<CheckBox xmlns:android=""
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:textSize="14sp" android:typeface="normal" android:textStyle="normal"

    android:layout_weight="0" android:layout_gravity="left" />

or in this function

private List<CheckBox> convertToListItem(String[] aux2){

        List<CheckBox> result = new ArrayList<CheckBox>();
        ArrayList<CheckBox> boxes = new ArrayList<CheckBox>();

        for (String text : aux2){
            CheckBox temp = new CheckBox(this);


return result;
What happens is: it appears the checkbox, but in front instead the right text it appears "android.widget.Checkbox@...."

What am I doing wrong ?
Posted 17-Jul-11 4:29am
Maxdd 71.5K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

one of the functions returns a string using the getString() of that class.

check this: search for "checkbox in listview" [^]@ android developer group @ google
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It should be used a listview with multiple choice mode[^]

public void onCreate(Bundle savedInstanceState) {

      setListAdapter(new ArrayAdapter<String>(this,
              android.R.layout.simple_list_item_multiple_choice, GENRES));

      final ListView listView = getListView();

Maxdd 7 18-Jul-11 8:14am
Much easier :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 18 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100