Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Developer 101

Developer 101 101 Tutorials



Reply
 
LinkBack Thread Tools
Old December 5th, 2011, 04:14 AM   #1 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add to spinner from array

Hi,

I've added a spinner to one of the pages within my app. When the page(activity) loads it calls a web service and the values that are returned need to be displayed within the spinner.

I've found lots of examples where you can add values from an array but the array values are always hard coded. I need to be able to add whatever is returned from the service into an array and then add that to my spinner.

Is this possible?

the phantom is offline  
Reply With Quote
Sponsors
Old December 5th, 2011, 06:16 AM   #2 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

Of course it's possible.

At the very simplest, you could stuff the values you get from the result of the web service into an array and then continue as per the examples.

A more sophisticated way would be to implement an Adapter by subclassing BaseAdapter. Your custom Adapter would bridge directly between the results of the web service and the spinner.
jiminaus is offline  
Reply With Quote
Old December 6th, 2011, 08:07 AM   #3 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Jiminaus, I was trying to over complicate what I was doing and found a very good video tutorial about it, problem solved

As you're very good at responding to my posts might I ask about another situation that I'm trying to resolve?

I have an activity that displays a tablelayout with a series of items in it, you can then select one of the items and click a button to open a 2nd activity which enables the user to change various details of the selected item using a form that connects to a web service. Once the confirm button is pressed and the service runs I need the 2nd activity to close (which is fine just using the finish() command) but then when the previous activity is displayed again after the second one is closed I need the first one to essentially refresh to show the updated values. Do I need to look at using the onResume() function? Any advice would be greatly received.
the phantom is offline  
Reply With Quote
Old December 7th, 2011, 02:42 AM   #4 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

Quote:
Originally Posted by the phantom View Post
I have an activity that displays a tablelayout with a series of items in it, you can then select one of the items and click a button to open a 2nd activity which enables the user to change various details of the selected item using a form that connects to a web service. Once the confirm button is pressed and the service runs I need the 2nd activity to close (which is fine just using the finish() command) but then when the previous activity is displayed again after the second one is closed I need the first one to essentially refresh to show the updated values. Do I need to look at using the onResume() function? Any advice would be greatly received.
I've typically seen this kind of thing done more in onStart(). But I think doing it in onResume() would also work.

See Managing the Activity Lifecycle | Activities | Android Developers for more details like the difference between onStart() and onResume().
jiminaus is offline  
Reply With Quote
Old December 8th, 2011, 10:06 AM   #5 (permalink)
Junior Member
 
Join Date: Oct 2011
Posts: 21
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again for the help! Much appreciated.

I've just tried to run my app on my phone and although it runs fine it has placed all of my class files from Eclipse onto my device? I take it I need to package it up properly into one executable?
the phantom is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development > Developer 101 User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:17 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo