Can anyone tell me what I’m doing wrong? It Eclipse isn’t giving me any errors or warnings, but my ListView isn’t being populated when i run the emulator. Any help is much appreciated. Thanks.
This is inside onCreate:
ListView bedList = (ListView) findViewById(R.id.refineBeds);
bedList.setVisibility(View.VISIBLE);
bedList.setAdapter(new MArrayAdapter(this, R.array.beds));
bedList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
This is a custom inner class I’m trying to use as my adapter:
private static class MArrayAdapter extends ArrayAdapter<String> {
public MArrayAdapter(final Context context, final int objects) {
super(context, R.layout.item_single, objects);
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
final CheckedTextView view = (CheckedTextView)
super.getView(position, convertView, parent);
view.setChecked(position == 2); return view;
}
}
Try first without a cusom layout like this, then eventually you can adjust it using your own layout: