I've a very basic question here: I'm creating an android list using an ArrayAdapter which populates data to a listView from a string array:
final String[] listData={"Red", "Green", "Blue",
"Purple", "Orange"};
final ListView lv=(ListView)findViewById(R.id.listView1);
final ArrayAdapter<String> aa=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listData);
lv.setAdapter(aa);
The above code works fine. My question is, why can't we use the following adapter implementation:
final ArrayAdapter<String> aa=new ArrayAdapter<String>(this, R.id.listView1, listData);
listView1 is the id of my ListView in activity_main.xml. I tried using this implementation but the application crashed. What am I missing here? Sorry if the question seems silly as I'm still learning how to program android! Thanks for your help!