Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Blog Reader Android App Rebuilding from Scratch All About @string Resources

Wei-Ting Chen
Wei-Ting Chen
7,632 Points

Why does "No item to display!" not showing up when we have "setListAdapter(adapter)"?

Hi every teachers & classmates, in the "activity_main_list.xml",we have

<listView>

and

<textView>

so what is the reason that only listView shows up in the emulator?

Also,after we comment the setListAdapter(adapter) and ArrayAdapter,the textView shows up again! Why?

thanks!

1 Answer

Hi Wei-Tin. I markdown your code so that the listView and textView tags can appear.

"so what is the reason that only listView shows up in the emulator?"

-According to what the instructor said, the android system will display the textView depending on whether there is data in the list or not. There is data in the list hence it won't display it.

"Also,after we comment the setListAdapter(adapter) and ArrayAdapter,the textView shows up again! Why?"

-Also setListAdapter binds the ArrayAdapter you created to the listView (which makes the list you have given it to appear), by commenting it, there is no list bound to the listView so it is practically empty hence that makes the textView display the "No items to display!" message.

I hope this helped.

You are welcome