Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7930837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:32:53+00:00 2026-06-03T20:32:53+00:00

Im trying to create a Spinners within a ListView, but i dont know how

  • 0

Im trying to create a Spinners within a ListView, but i dont know how to get all the values of each spinner in a List of strings for example. This is the code of the Adapter:

public class CustomizeColumnsListAdapter : BaseAdapter
{
    private Activity context;
    private int columnsCount;
    public List<string> fieldsValues;

    public CustomizeColumnsListAdapter(Activity context, int columnsCount)
    {
        this.context = context;
        this.dataObject = dataObject;
        this.columnsCount = columnsCount;
    }

    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        RelativeLayout view = (convertView
                        ?? context.LayoutInflater.Inflate(
                                Resource.Layout.customize_column_list_item, parent, false)
                    ) as RelativeLayout;

        try
        {
            string[] sortingColumsItems = {"None", "Id", "Customer Name", "Customer Number", "City", "Address", "Credit Limit", "Contact Name", "Phone Number", "Mail"};
            ArrayAdapter<string> spinnerArrayAdapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, sortingColumsItems);
            spinnerArrayAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            view.FindViewById<Spinner>(Resource.Id.cboCCD).Adapter = spinnerArrayAdapter;
            view.FindViewById<Spinner>(Resource.Id.cboCCD).Enabled = true;

            if(columnsCount>=position)
            {
                string columnIndex = (position + 1).ToString();
                view.FindViewById<TextView>(Resource.Id.lblColumn).Text = columnIndex;
            }

        }
        catch (System.Exception ex)
        {
            Toast.MakeText(context, ex.ToString(), ToastLength.Short).Show(); 
        }

        return view;            

    }

    public override int Count
    {
        get { return columnsCount; }
    }

    public override Java.Lang.Object GetItem(int position)
    {
        return null;
    }

    public override long GetItemId(int position)
    {
        return position;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:32:54+00:00Added an answer on June 3, 2026 at 8:32 pm

    If you’re looking to present the user with a way to launch a spinner from each row of the list, one approach would be to use a custom view such as the following SpinnerRow:

    public class SpinnerRow : RelativeLayout, View.IOnClickListener, IDialogInterfaceOnClickListener
    {
        #region Member Variables
        SpinnerItemSelectedDelegate _spinnerItemSelected;
        SpinnerPosSelectedDelegate _spinnerPosSelected;
    
        private TextView _label;
        private TextView _value;
        private ImageButton _edit;
        private string[] _options = new String[0];
        private int _position;
    
        private AlertDialog.Builder _builder;
        #endregion
    
        #region Construction
        public SpinnerRow (Context context) :
            base (context)
        {
            Initialize (context, null);
        }
    
        public SpinnerRow (Context context, IAttributeSet attrs) :
            base (context, attrs)
        {
            Initialize (context, attrs);
        }
    
        protected SpinnerRow (IntPtr doNotUse, Android.Runtime.JniHandleOwnership owner) :
            base (doNotUse, owner)
        {
            //Do nothing
        }
    
        protected void Initialize (Context context, IAttributeSet attrs)
        {
            Inflate (context, Resource.Layout.SpinnerRow, this);
    
            _label = FindViewById<TextView>(Resource.Id.editscope_addons_spinner_row_lbl);
            _value = FindViewById<TextView>(Resource.Id.editscope_addons_spinner_row_spin_lbl);
            _edit = FindViewById<ImageButton>(Resource.Id.editscope_addons_spinner_row_button);
    
            _label.Text = "Row label";
            string[] options = {"None", "Id", "Customer Name", "Customer Number", "City", "Address", "Credit Limit", "Contact Name", "Phone Number", "Mail"};
            _options = options;
    
            _edit.SetOnClickListener(this);
    
            _builder = new AlertDialog.Builder(context);
            _builder.SetTitle(_label.Text);
        }
        #endregion
    
        public virtual void OnClick(View v)
        {
            _builder.SetSingleChoiceItems(_options, _position, this);
            _builder.Create().Show();
        }
    
        public virtual void OnClick(IDialogInterface dialog, int position)
        {
            Position = position;
            _value.Text = _options[_position];
    
            dialog.Dismiss();
        }
    
        public int IndexOf(string option)
        {
            int numOptions = _options.Length;
            for (int i = 0; i < numOptions; i++)
            {
                if (_options[i].ToLower() == option.ToLower())
                    return i;
            }
    
            return IntentConstants.INVALID_POSITION;
        }
    
        public bool Contains(string option)
        {
            return IndexOf(option) != IntentConstants.INVALID_POSITION;
        }
    
        #region Properties
        public string Text
        {
            get { return _label.Text; }
            set { _label.Text = value; }
        }
    
        public int Position
        {
            get { return _position; }
            set
            {
                _position = value;
                if (_position == IntentConstants.INVALID_POSITION)
                {
                    _value.Text = NotSelectedText;
                    if (OnSelected != null)
                        OnSelected("");
                }
                else if (_options != null && _options.Length > 0)
                {
                    _value.Text = _options[_position];
                    if (OnSelected != null)
                        OnSelected(_options[_position]);
                }
    
                if (OnPosSelected != null)
                    OnPosSelected(_position);
            }
        }
    
        public string ValueText
        {
            get { return _value.Text; }
        }
    
        public String[] Options
        {
            get { return _options; }    
            set 
            { 
                _options = value;
    
                //Reset the current position so the text is updated
                int curPos = Position;
                _position = IntentConstants.INVALID_POSITION;
                Position = curPos;
            }
        }
    
        public SpinnerItemSelectedDelegate OnSelected
        {
            get { return _spinnerItemSelected; }
            set { _spinnerItemSelected = value; }
        }
    
        public SpinnerPosSelectedDelegate OnPosSelected
        {
            get { return _spinnerPosSelected; }
            set { _spinnerPosSelected = value; }
        }
        #endregion
    }
    

    You would initialize this view within the GetView() of your CustomizeColumnsListAdapter above.

    One other thing you’ll likely want to consider in that method is the ViewHolder pattern recommended by Android: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the following to create a Spinner . But I get
I'm all new to Android and I'm trying to create a spinner programmatically and
I am trying create my custom Style spinner with help of this site. But
I'm trying to get an onClickListener to fire on a Spinner, but I get
I'm trying to create a new spinner background using a 9 patch picture. I've
I'm trying to implement multiple spinners within one activity, which appears to be working
I am trying to create a view in iOS to let the user know
I'm trying to create a custom attribute called Tag for all editable elements. I
Greetings all, I'm trying to create a specific layout that should be very simple
I am trying create alert dailog using glade,but its not working .am i doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.