Quantcast

spinner with icons and text

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

spinner with icons and text

vergatario
Guys am new to mono for android, I would like to display a spinner with icons and text, so far i have:

int[] icons = { Resource.Drawable.icon, Resource.Drawable.icon };
ArrayAdapter adapter = new ArrayAdapter<int>(this, Android.Resource.Layout.SimpleSpinnerItem, icons);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleGalleryItem);
Spinner spinner= FindViewById<Spinner>(Resource.Id.MyTypes);
spinner.Prompt = "Select Card Type";
spinner.Adapter = adapter;


But of course this simply will render the integer representation of the image into the spinner. Can anyone point me into the right direction?

Thanks in advance!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spinner with icons and text

Tomasz Cielecki

Implement your own adapter. In that you can set the displayed views to anything you want.

On 26 Feb 2013 03:18, "vergatario" <[hidden email]> wrote:
Guys am new to mono for android, I would like to display a spinner with icons
and text, so far i have:

*int[] icons = { Resource.Drawable.icon, Resource.Drawable.icon };
ArrayAdapter adapter = new ArrayAdapter<int>(this,
Android.Resource.Layout.SimpleSpinnerItem, icons);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleGalleryItem);
Spinner spinner= FindViewById<Spinner>(Resource.Id.MyTypes);
spinner.Prompt = "Select Card Type";
spinner.Adapter = adapter;*

But of course this simply will render the integer representation of the
image into the spinner. Can anyone point me into the right direction?

Thanks in advance!



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/spinner-with-icons-and-text-tp5712941.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spinner with icons and text

johnbowick
In reply to this post by vergatario
In my app, I have a Spinner, that can be filled with two Arrays of Strings, stored in my values/strings.xml resource. Depending on the state of two RadioButtons, the values from the correct Array is selected and my Spinner gets filled.

For each Array of Strings, I have an Array of Icons which have the same size. All of my icons start with an "A" and are followed by a number. I can't change this, it's stored like that in the database. I have an Array in Strings.xml with all the numbers I require to draw the icons. All the actual icons can be found in the drawable resource folder.

Now I want to show the corresponding item next to the String from the list which was selected by the Spinner. When an item gets selected, I just need to see the text.

I have searched the Internet for a good tutorial, but with what I have found I have not succeeded in doing this. I'm just beginning in Android programming so I think I need a little help. I hope that somebody can guide me in the right direction.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spinner with icons and text

vergatario
John,

Am not sure if what you want to accomplish is display a drop down with icon and text, if so, you can do it by using a custom adapter for your spinner.  i will try to provide a code snippet for you to check

Fernando Cordero
407-574-1948


> Date: Tue, 5 Mar 2013 21:27:33 -0800

> From: [hidden email]
> To: [hidden email]
> Subject: Re: [mono-android] spinner with icons and text
>
> In my app, I have a Spinner, that can be filled with two Arrays of Strings,
> stored in my values/strings.xml resource. Depending on the state of two
> RadioButtons, the values from the correct Array is selected and my Spinner
> gets filled.
>
> For each Array of Strings, I have an Array of Icons which have the same
> size. All of my icons start with an "A" and are followed by a number. I
> can't change this, it's stored like that in the database. I have an Array in
> Strings.xml with all the numbers I require to draw the icons. All the actual
> icons can be found in the drawable resource folder.
>
> Now I want to show the corresponding item next to the String from the list
> which was selected by the Spinner. When an item gets selected, I just need
> to see the text.
>
> I have searched the Internet for a good tutorial, but with what I have found
> I have not succeeded in doing this. I'm just beginning in Android
> programming so I think I need a little help. I hope that somebody can guide
> me in the right direction.
>
>
>
> -----
> Best Android Tablets
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/spinner-with-icons-and-text-tp5712941p5712994.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Loading...