ArrayAdapter<String> NEVER works.

A

AC Question

What is up with Android Studio.? I have tried for 18 days to populate a simple listView and it never work's.! It work's in XML but not MainActivity.

I am copying and pasting code from Android's own web page's showing you how to use ArrayAdapter<String> to populate the listView widget, and I always get "errors".

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, myStringArray);

ListView listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);

.setAdapter(adapter); alway's show's error's all the way across. Here is the Array I constructed using Oracle's own tutorial.

String [] myStringArray = {

one, two, three, four, five, six, seven, eight, nine, ten
};

I have been to Github, Stack Overflow, GrepCode, and Oracle's Java tutorial's and nothing work's.? I also found it very short sighted that you can not use some form of android:eek:nClick in listViews XML to set up Intent's in MainActivity like you do with button's. Instead, you have to construct all this onItemClick code when they should have just made listView out of button's and not TextView's.
 

Forum statistics

Threads
943,150
Messages
6,917,532
Members
3,158,850
Latest member
kerokekerol