• 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

Problem with refreshing listview from a dialog window

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a listview and my implementation of the CursorAdapter. As a
part of my list item I have a delete button. When the user presses the
button I show a dialog asking for confirmation and if the user presses
ok I delete the item from the database. The problem is with refreshing
the listview. I tried calling cursor.requery() and
mAdapter.notifyDataSetChanged() (separately or both) but that doesn't
help. Requery clears the list and it re-appears (without the missing
item) after re-entering the activity. notifyDataSetChanged does
nothing (the item is still on the list) and again it is ok after re-
entering the activity. I have managed to make this working after
reloading the whole database:

But reloading the whole db seems to be a very expensive task and I'm
quite sure there must be a better way to do this.

I also have another problem - my listview items are defined by a
relativelayout. However the layout seems to be ignoring all 'vertical'
attributes, like alignParentBottom or centerVertical. I have seen an
google I/O with Romain Guy and he answered a similar question by
saying we should pass the parent ViewGroup followed by false, to the
inflate function, but that still doesn’t solve my problem. Don’t know
what is going on here. I solved this by placing my items below some
others and playing with the margin/padding but I don’t really like
that solution.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic