• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ListView empty

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to display the contents of a ListView I created but I only watch a white screen. The idea is to retrieve data of a database and put then in an ArrayList in order to display them. The ArrayList is of type Lugar that is a class.

Here is the code:



The code of class Lugar:



When I run the app there are no errors. I only watch a white screen. It seems ListView is empty and I don't know why.

How can I display data? I have data in the database.

Thanks.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a couple of Toasts that get called when you populate the list, do they get displayed? If not, then you have to figure out why your cursor is empty (on a related note, you shouldn't do this: while(cl.isLast() == false). You should do this instead: while(!cl.isLast()). When comparing the return statement of a method it isn't a big deal, but when you do == true or == false using variables there is a critical mistake you can make. So it is best to avoid that habit altogether).

You show the code for Lugar, but not LugarAdapter. Does it properly inform the ListView it is attached to that there are values in the list?

What is your layout like? Does the ListView have a non-zero height? How about the views used to display the items in the list? Are they sized properly to show content?
 
Alex Munozz
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Toasts are for checking if the values are correct. And the toast that I don't watch anything on the screen is this one:



What I only see is [].

The code for the ListAdapter is:



The layouts:

ListView layout:



Items Layout:



There are no errors. The cursor has data. The Lugar class I think it's empty.

How can I watch data in the cursor?

Thanks.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alex Munozz wrote:Toasts are for checking if the values are correct. And the toast that I don't watch anything on the screen is this one:



What I only see is [].


So lugrs is empty. You also have Toast inside the while loop. Do they show up at all? If they don't then one of the following is true:
1. The cursor cl is null
2. cl has zero elements
3. There is only one row in the cursor (the first row is the last row. Your while loop is designed never to look at the last row.)
 
Alex Munozz
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer. The problem is fixed. The issue was the loop:



I changed cl.isLast() for cl.isAfterLast() and I also put the creation of the object Lugar inside the loop.



And finally I can watch data from the cursor.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic