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 Android Lists and Adapters (2015) Standard ListViews Introducing ListView and ListActivity

Jason S
Jason S
16,247 Points

How does textview refer to the listview to be empty?

how does the textview connected to the listview other than they are in the relative layout? could i have two listviews and wouldn't the textview not know which one it would be referring to?

1 Answer

I think in that case you can explicitly define which textview is the empty text for each listview. have a look at the listView.setEmptyView documentation

Jason S
Jason S
16,247 Points

ohh so if you only have one listview then the textview automatically assumes that it is referring to that listview?

As long as that textView has the id of @android:id/empty and the listView has the id of @android:id/list then yes it will automatically act as the empty text for the listview