listView.setAdapter doesn't work
Posted
by
Bowiz2
on Stack Overflow
See other posts from Stack Overflow
or by Bowiz2
Published on 2012-09-29T21:33:47Z
Indexed on
2012/09/29
21:37 UTC
Read the original article
Hit count: 197
I have a listview called quotesList, and I am trying to use an adapter to put information in it. Here is my code:
ListView listView = (ListView) findViewById(R.id.quotesList);
String[]values={"Android","iOS","Windows Phone","Other Stuff"};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1,values);
listView.setAdapter(adapter);
The only error that Eclipse shows is in the listView.setAdapter(adapter) line. The bold represents where the red squiggly is.
Syntax error on token "adapter", VariableDeclaratorId expected after this token
The period after listView gives an error as well, but I'm pretty sure its just related to the other error, as its a syntax error. Syntax error on token(s), misplaced construct(s) Thanks in advance!
© Stack Overflow or respective owner