Reputation: 95
I have a listview that I want to show several items. However, after the program compiles, nothing shows up and I am unsure as to why.
ListView listView = findViewById(R.id.quikList);
ArrayList<String> list = new ArrayList<String>();
list.add("Hello");
list.add("Is it me youre looking for?");
list.add("I can see it in your smile and I want so badly to make this listview work");
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, list);
listview.setAdapter(aa);
I don't know why this pretty basic task is not working. I think it might be due to android.R.id.text1, but I'm not sure as to why. Any sort of light anyone can shed on this topic would be fantastic.
Upvotes: 3
Views: 142
Reputation: 161
Try this:
ListView listView = (Listview)findViewById(R.id.quikList);
String list[] = {"Hello","Is it me youre looking for?","I can see it in your smile and I want so badly to make this listview work"};
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.simple_list_item_1, R.id.textView, list);
listview.setAdapter(aa);
Upvotes: 1
Reputation: 8282
No need of 3rd param just remove this line android.R.id.text1
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, list);
listView.setAdapter(aa);
Solution 2:
May be your theme issues which means your Textview
color same as Listview
background color..
so just change your listview background color...
android:background="@android:color/holo_red_dark"
Upvotes: 1