The list view empty view is not shown (SDK m3-rc37a)

Put your problem here if it does not fit any of the other categories.

The list view empty view is not shown (SDK m3-rc37a)

Postby kalkar.prashant » Tue Feb 26, 2008 1:31 pm

Hi,

I am using a listview and I have setup the empty view for the list view as follows:


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView emptyListTextView = new TextView(this);
  2.  
  3. emptyListTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  4.  
  5. emptyListTextView.setId(android.R.id.empty);
  6.  
  7. emptyListTextView.setText("Empty"
  8.  
  9. userListView = (ListView) findViewById(android.R.id.list);
  10.  
  11. userListView.setEmptyView(emptyListTextView);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


but nothing appears when the list is empty. I have not defined the empty view in the xml file, but am adding the empty view like above.

Please help.

Regards,
Prashant
kalkar.prashant
Freshman
Freshman
 
Posts: 4
Joined: Tue Feb 26, 2008 12:00 pm

Top

Postby plusminus » Tue Feb 26, 2008 3:25 pm

Hello kalkar.prashant,

Why not upgrading to m5 :?:

Should be working also without this :darrow:. By writing it the ID is used twice which probably causes problems.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. emptyListTextView.setId(android.R.id.empty);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


You should define such things in JavaCode only if there is no other way to do it in XML!

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests