1 Sept 2014

Radio Listview | custom listview with Radio in android

Hello Friends,

This tutorial shows you how to add android radio button in a list view. We will develop custom adapter to populate our android list view with 
radio button.



NOTE : Please find rest implementation from this post 


Step 1: selector_radiobutton.xml
-Change radio images in selector 


Step 2: ItemAdapter.java 

-Change below logic from existing code in Item Adapter getView ()

view.setOnClickListener(new View.OnClickListener()
                     {
                           public void onClick(View v)
                           {
                                  for (int i = 0; i < arraylistData.size(); i++)
                                  {
                                         if (i == position)
                                         {
                                                ItemBean bean = arraylistData.get(position);
                                                if (bean.isSelected())
                                                {}
                                                else
                                                {
                                                       bean.setSelected(true);
                                                }
                                         }
                                         else
                                         {
                                                ItemBean bean = arraylistData.get(i);
                                                bean.setSelected(false);
                                         }
                                         notifyDataSetChanged();
                                  }
                           }

                     });


I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)