Using CursorAdapter What is what?

by Moto » Tue, 30 Jun 2009 06:45:50 GMT


Sponsored Links
 I been using custom adapters based on the BaseAdapter and I usually
populate my data at the getView() funtion.

Now I'm trying to write my custom adapter for my database cursor which
now will be based on a CursorAdapter.

I'm getting confused where I should do the populating work...??  Along
with how do I implement my inflating and populating "smart/efficient
code based on RomainGuy presentation..." ??

Thanks for the help!
-Jona
--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Mark Murphy » Tue, 30 Jun 2009 06:47:57 GMT


 


Override newView(), and in there inflate new rows. That will only be
called when there is no existing row to recycle.

Also override bindView(), and in there pour your Cursor's data into the
supplied row.

I usually implement this such that newView() inflates the row, then
calls bindView(), so all my data-binding logic can be in one place.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Looking for Android opportunties?  http://wiki.andmob.org/hado 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Using CursorAdapter What is what?

by Moto » Tue, 30 Jun 2009 07:17:22 GMT


 Nice!

Along with that I attached a tag to the newView so that bindView would
not have to go and find my view IDs on the xml...  A little extra opt!

Thanks Mark!
Moto!

--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Moto » Tue, 30 Jun 2009 07:22:04 GMT


 Let me add to the blog:

How can I:  if item was deleted and there are no items left on the
list... How could this custom adapter know this happen? I want to set
a different view based on that case...

Thanks!
--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Mark Murphy » Tue, 30 Jun 2009 07:26:24 GMT


 


The data source for the Cursor (SQLiteDatabase, ContentProvider, etc.)
is hopefully notifying the Cursor of data changes.

Worst-case, call requery() on the Cursor.

Either way, the list should update itself to match.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Development Wiki:  http://wiki.andmob.org 

--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Moto » Tue, 30 Jun 2009 07:30:24 GMT


 Sorry for not giving any details on that post.  I assumed that what
you are saying was already happening...  So in the case I delete the
item my list does get updated but now its blank since there are no
items on my database.  I want to handle this case by applying a new
view which would tell the user, "hey my table is empty!"
--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Mark Murphy » Tue, 30 Jun 2009 07:42:22 GMT


 


Ah.

Try Cursor#registerDataSetObserver(). That will let you know when the
data has changed. You can then ask the Cursor to getCount(), and
therefore detect the empty-list condition.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Development Wiki:  http://wiki.andmob.org 

--~--~---------~--~----~------------~-------~--~----~



Using CursorAdapter What is what?

by Moto » Tue, 30 Jun 2009 07:52:30 GMT


 Nicey nicey!

Thanks Mark great help!
Moto!
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Urgent - Setting timed expiry for application to be submitted to adc2

Thanks Mark

I was refering to the below line in the main android developer page.

"2. The main ADC2 page *does* mention the use of a "timed expiration"
trial version, but this is not mandatory. "

I have implemented exactly what you have adviced, just wanted to know
if there are anything better that can be done, or if something can
used in addition to the above said method just as a precaution.


--~--~---------~--~----~------------~-------~--~----~

2. Urgent - Setting timed expiry for application to be submitted to adc2

Hi Guys,

I am submitting an application to the android developer challenge 2,
but i would like to sell my application after the competition is over.
In the terms and conditions google has mentioned that in case if i
have to sell the application after the contest is over I have to set a
timed expiry date.

But while going through the steps for publishing the applications it
is mentioned that the certificate validity limit should be a minimum
of 22 October 2003.

"1.Your application must be signed with a cryptographic private key
whose validity period ends after 22 October 2033. "

Is it possible for me to set the expiration date as 120 days in the
certificate? If not what is the best proccess that i should be
following to set a timed expiry period?

Thanks in advance,
R.Karthik
--~--~---------~--~----~------------~-------~--~----~

3. glGenTextures returning 0

4. cupcake Vs donut Vs eclairs

5. Test on a real HTC Magic via the web

6. How to add the image on surface view?

7. Playing multiple sounds at once?