Hello,
I am trying to create a listview that has check box beside each item. (i am following a code from the book android), but i can't get it to work, every time i run it, it crashes. since i am very new to this android staff, i have no clue what to do to get it to work, any help is appreciated.the code is below.
*i have created two layout files in names of list and list_item.
the code for the main activity:
public class ListDemoActivity extends ListActivity {
/** Called when the activity is first created. */
String[] listItems = {"exploring", "android","list", "activities"};
private SimpleCursorAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.lists);
//setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, listItems));
//setContentView(R.layout.lists);
Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
String[] cols = new String[]{People.NAME};
int[] names = new int[]{R.id.row_tv};
adapter = new SimpleCursorAdapter(this,R.layout.list_item,c,cols,names);
this.setListAdapter(adapter);
}
}
the lists file content:
<?xml version="1.0" encoding="utf-8"?>
and the list_item file content:
<?xml version="1.0" encoding="utf-8"?>