0
public class MainActivity extends Activity implements OnItemClickListener{

ArrayAdapter<String> arr;
ListView list;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String[] st = {"aa","bb","cc"};
    list = (ListView)findViewById(R.id.listView1);
    arr = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, st);
    list.setAdapter(arr);
    list.setOnItemClickListener(this);
}


@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub
    list.setItemChecked(arg2, true);
}

}

It's really simple code, and still the boxes do not check. This means I don't understand something.

Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
Yogi_Bear
  • 512
  • 2
  • 10
  • 24

1 Answers1

0

Well I found the problem to all my questions! (and there were quit a few of them)

and the problem was when I did the xml

<ListView
    android:id="@+id/stationsList1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

  **android:choiceMode="multipleChoice"**

>

forgot that...

Yogi_Bear
  • 512
  • 2
  • 10
  • 24