title: Radio button in recyclerview with kotlin MVVM and databinding
body: <p>Redio button in recyclerview with kotlin, dagger2, retrofit , livedata, MVVM and databinding,I need updated list from videModel and also set selected positions to find it
  is selected and other on is deselected. please suggest how to select only one in RadioButton in List.
  <strong>here are my adapter:-</strong> </p>
  
  <pre><code>class DocTypeListAdapter : RecyclerView.Adapter&lt;DocTypeListAdapter.ViewHolder&gt;() {
      private lateinit var postList: List&lt;DriverType&gt;
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DocTypeListAdapter.ViewHolder {
          val binding: ItemDocumentTypeBinding =
              DataBindingUtil.inflate(LayoutInflater.from(parent.context), R.layout.item_document_type, parent, false)
          return ViewHolder(binding)
      }
  
      override fun onBindViewHolder(holder: DocTypeListAdapter.ViewHolder, position: Int) {
          holder.bind(postList[position], position, mSelectedItem)
      }
  
      override fun getItemCount(): Int {
          return if (::postList.isInitialized) postList.size else 0
      }
  
      fun updatePostList(postList: List&lt;DriverType&gt;) {
          this.postList = postList
          notifyDataSetChanged()
      }
  
      class ViewHolder(private val binding: ItemDocumentTypeBinding) : RecyclerView.ViewHolder(binding.root) {
          private val viewModel = DocTypeListViewModel()
  
          fun bind(post: DriverType, position: Int, selectedPosition: Int) {
  //            viewModel.bind(post,true)
              viewModel.bind(post,position,selectedPosition)
  
  //             mRadioButton : RadioButton = binding.radioButton;
  
  
  
              viewModel.readioButtonClicked(getAdapterPosition(),position)
              binding.viewModel = viewModel
          }
      }
  }
  </code></pre>
  
  <p>viewModel Like:- </p>
  
  <pre><code>class DocTypeListViewModel : BaseViewModel() {
      private val postTitle = MutableLiveData&lt;String&gt;()
      private val postBody = MutableLiveData&lt;String&gt;()
       val isChecked = MutableLiveData&lt;Boolean&gt;()
      private var mSelectedItem = -1
  
  
      fun bind(post: DriverType, position: Int, selectedPosition: Int) {
          postTitle.value = post.driver_type
          postBody.value = post.description
  
          if ((selectedPosition == -1 &amp;&amp; position == 0))
              isChecked.value = true
          else
              if (selectedPosition == position)
                  isChecked.value = true
              else
                  isChecked.value = false
  
      }
  
      fun getPostTitle(): MutableLiveData&lt;String&gt; {
          return postTitle
      }
  
      fun getPostBody(): MutableLiveData&lt;String&gt; {
          return postBody
      }
  
      fun getIsChecked(): MutableLiveData&lt;Boolean&gt; {
          return isChecked
      }
  
      fun readioButtonClicked(selectedPosition: Int, pos:Int) {
          mSelectedItem = selectedPosition
  
          //            mSelectedItem=getAdapterPosition()
  //            notifyDataSetChanged()
  
      }
  }
  </code></pre>
  
  <p>my layout:- </p>
  
  <pre><code>&lt;android.support.v7.widget.RecyclerView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  app:adapter="@{viewModel.getDocTypeListAdapter()}"
  
                  android:layout_marginTop="8dp"
                  app:layout_constraintTop_toBottomOf="@+id/textView9"
                  app:layout_constraintStart_toStartOf="parent"
                  android:layout_marginStart="8dp"
                  app:layout_constraintEnd_toEndOf="parent"
                  android:layout_marginEnd="8dp"
                  android:id="@+id/recyclerView"
                  android:layout_marginBottom="8dp"
                  app:layout_constraintBottom_toTopOf="@+id/button"/&gt;
  </code></pre>
  
  <p>binding adpter:-</p>
  
  <pre><code>@BindingAdapter("adapter")
  fun setAdapter(view: RecyclerView, adapter: RecyclerView.Adapter&lt;*&gt;) {
      view.adapter = adapter
  }
  </code></pre>