1

Possible Duplicate:
Spinner with checkbox items, is it possible?

i want to add a checkbox in every row of my spinner so that when the use click on any row the checkbox should get checked and indicated that a particular row is clicked. i don't know how to do this please help me in doing that. my list is coming dynamically .

this is my spinner

MYspinner = new CustomSpinnerAdapter(getApplicationContext(),
                Arrays.asList(getResources().getStringArray(R.array.pl_latest)));

MYspinner .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        ratingSpinner.setAdapter(spinnerAdp);

this is my constructor

public CustomSpinnerAdapter(Context listContext, List<String> asList) {
        super(listContext, R.layout.textview_grey_rounded, asList);

        // TODO Auto-generated constructor stub
    }

textview_grey_rounded.xml

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textSize="16dip" 
    android:singleLine="True" 
    android:textColor="#ffffff"
    android:id="@+id/myText" 
    android:gravity="center" 
/> 
Community
  • 1
  • 1

2 Answers2

0

This i a duplicate questions: Spinner with checkbox items, is it possible?

To be a bit more helpful to you, I would suggest not using a spinner for this, but using a dialog. You could use a single-choice AlertDialog and style the rows to have checkboxes. If you really want to get the "spinner" feel, you can also use a Button to open it and style that to look look the spinner button as well.

Community
  • 1
  • 1
SBerg413
  • 14,515
  • 6
  • 62
  • 88
0

Additioanally you have to override adapter's getView method where you can implement anything you like to show or hide additinal markers in your item view. Just keep in mind that adapter reuses inflated item views and so you always have to check if convertView parameter is not null - that will be the view to be reused.

slkorolev
  • 5,883
  • 1
  • 29
  • 32