O'Reilly logo

50 Android Hacks by Carlos Sessa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Working with lists and adapters

Lists and adapters are two of the main concepts to master in Android development. In this chapter, you’ll learn several tips and tricks you can use with lists and adapters.

Hack 24 Handling empty lists: Android v1.6+

A common way to show data to the user in mobile platforms is to place it inside a list. When you do this, you need to handle two cases: the ordinary list full of items and an empty state. For the list, you’ll use a ListView, but how do you handle the empty state? Fortunately, there’s an easy way to achieve this. Let’s look at how to do it.

ListView and other classes that extend AdapterView easily handle emptiness through a method called setEmptyView(View). When the AdapterView needs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required