Put an ArrayList in a ScrollView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Put an ArrayList in a ScrollView

Postby sephyroth69 » Tue Jan 12, 2010 4:16 pm

Hi all,

I'm quite new in Android programming and I'm trying to put the result of a SQL query (which is an ArrayList if i'm not mistaken) into a ScrollView. That way, each time I update the database the scrollview would be updated too.

Thx from this forum, I've learned quite a lot already.
sephyroth69
Freshman
Freshman
 
Posts: 8
Joined: Tue Jan 12, 2010 11:02 am

Top

Postby jwei512 » Wed Jan 13, 2010 3:41 am

Hello,

I don't think the result of your SQL query should be an arraylist, but it should be a Cursor that points to the table (which is the result of your SQL query).

Then what you do is create a CursorAdapter using the given cursor (i.e. could use a SimpleCursorAdapter) and then you call setListAdapter in your Activity and give it the CursorAdapter that you made.

Once you set the ListAdapter in your ListActivity, when the underlying SQL data changes, just call the adapter's notifytDataChange() and your list will refresh itself.

Does this make sense?
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby sephyroth69 » Wed Jan 13, 2010 9:48 am

Thank you for your answer, it does make sense.
I'll have a look today a bit later if I have time and keep you posted
sephyroth69
Freshman
Freshman
 
Posts: 8
Joined: Tue Jan 12, 2010 11:02 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests