Setting empty text on listView that does not have @+android:list as its ID?

by Lee » Thu, 10 Sep 2009 09:25:12 GMT

Sponsored Links
 I've got a tabhost that has a number of tabs that all contain a
ListView (among other widgets).

I need to address each ListView separately and so they all have a
unique ID that is not @+android:list.

How does one define the empty text for a list if the only way that it
can be done is through the assumption that the list will have an id of
@+id/android:list and the empty text @+id/android:empty


Setting empty text on listView that does not have @+android:list as its ID?

by Mark Murphy » Thu, 10 Sep 2009 09:33:15 GMT


For an empty list, just make the ListView be invisible
(setVisibility(View.INVISIBLE)) and make an associated TextView be
visible. Use FrameLayout (or RelativeLayout) so they can take up the
same space in the GUI, just one or the other being visible.

Mark Murphy (a Commons Guy)  | 

_Android Programming Tutorials_ Version 1.0 Available!


Sponsored Links

Other Threads

1. Android Javadoc in eclipse

Hi All,

In the process of learning android API it would be very useful to be able to 
see the Javadoc right inside eclipse without having to switch to the browser.

Has anyone tried to set this up?




2. Spinner displays first item instead of selected item

hi there,

some Spinner is driving me crazzzyyy:

i am using a Spinner layout element bound to a SQLite-Table by a
SimpleCursorAdapter. The Spinner so far works fine: it lets me click
and select an item and it displays the selected item afterwards in
it's compact view.

For some features of my app I am also using the Spinner's
setSelection(int position) - method to set the spinner's position
programmatically. But then I get a strange behavior there: when I
select an item by setSelection(int position) the Spinner shows the 1.
item in the compact view but the correctly selected item in it's
dropdown view. Whenever this happens and the Spinner shows the wrong
item, it's getSelected-method returns the correct position that was
set before (>0). This behavior does not happen always, it seems that
it happens after rebinding data to the Spinner and selecting an item.

funny thing is: when i use the setSelection(int position, boolean
animate)-method, the Spinner's data behavior is ok and the item-
position-bug is gone. All I do is changing the setSelection-method to
setSelection(position, false) and compile the app: spinner's data
behavior is fine!
but then I get some display issues for that same spinner. I just
changes a single line of code and the spinner now draws a paddingTop-
spacing when it measures it's dimension the first time. after layout
is drawn a simple invalidate() will bring the Spinner to it's correct
place within the layout.

Does anyone know how to get rid of this Spinner-bug? Does anyone know
a workaround? It seems to be a framework bug within some of the
spinner's methods. the bug occurrs in emulator (tested: 1.5, 2.1, 2.2)
and on physical phone HTC hero (android 1.5) and nexus one (android

thanks a lot!


3. Custom View changing size

4. Wifi getScanResults() on Emulator

5. Market comments disappearing over last few days

6. Save SMS in outbox

7. Record Voice Message & Send it via Email