
How to store and remove checkBox data from SharedPreference? We have use the Log and toast to check what happen when we click on Checkbox.Ībove using this step you can successfully build spinnerWithCheckbox,If you want to add SharedPreference you can continue to read. The next step is to create a method onCheckedChanged inside of this we will check the isFromView is true when we click on the checkbox to check this pass the statement listState.get(position).setSelected(isChecked) When the spinner load we don’t want to show First spinner with check for this we will hide the visibility of the checkbox. setChecked function.Through (listState.get(position)) will give the data for the textView and checkBox. Inside If statement create LayoutInflater and assign the layout spinner_list, and instantiate textview and checkbox using holder.Īfter this set text and checkbox data using. Now in getCustomView, you need to make ViewHolder final and check the convertView should be not null, ConvertView is like a list. Inside the ViewHolder Declare the textview, and checkbox. Next create three methods for this type on editor getDropDownView, getView, getCustomView, and ViewHolder. Now create Adapter class and extends to ArrayAdapter and hook the context,ArrayList,MyAdapter,boolean.Īfter doing this create constructor using shortcut Alt + Insert and ,if it show red balloon then click on red balloon and implement rest methods. To create getter and setter press Alt + Insert or right inside the class file and click on generate then click on getter and setter options. This above was all UI part,Now we will go to class file and create Model.classĬreate Model.class and type copy the below after this generate getter and setter of both.


Now create spinner_list.xml in the layout file and add a checkbox, textview inside of it.Īfter this add all the text which you want to show with a checkbox into itemName Inside the strings.xml

We will go step by step before this first create a new android project and open the activity_main.xml. For spinner Three classes are used are the following
