title: Android studio radio button single select and The record button is clicked
body: <p>I have ten questions from my succession. I want to do,</p>
  
  <p>1-  an answer to a problem (only one button should be clicked)</p>
  
  <p>2- When I go to the next question, see the answer I clicked radiobutton the previous</p>
  
  <p>JAVA  Class</p>
  
  <pre><code>   public class Sinavsorulari extends Activity {
  
      TextView tv_soruNum, tv_soru;
  
  
      RadioButton rb_a, rb_b, rb_c, rb_d;
      Button btn_sonrakiSoru,btn_oncekiSoru , btn_kaydet;
  
  
      String url = "http://192.168.56.2/soru_cekme.php";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_sinav_sorulari);
  
  
  
          tv_soruNum=(TextView)findViewById(R.id.tv_soruNum);
          tv_soru=(TextView)findViewById(R.id.tv_soru);
          btn_oncekiSoru=(Button)findViewById(R.id.btn_oncekiSoru);
          btn_sonrakiSoru=(Button)findViewById(R.id.btn_sonrakiSoru);
          btn_kaydet = (Button) findViewById(R.id.btn_kaydet);
          rb_a = (RadioButton) findViewById(R.id.rb_cevapa);
          rb_b = (RadioButton) findViewById(R.id.rb_cevapb);
          rb_c = (RadioButton) findViewById(R.id.rb_cevapc);
          rb_d = (RadioButton) findViewById(R.id.rb_cevapd);
  
          btn_oncekiSoru.setEnabled(false);
          btn_kaydet.setEnabled(false);
          btn_kaydet.setVisibility(View.INVISIBLE);
          new HttpAsyncTask().execute(url);
  
      }
  
      private class HttpAsyncTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... urls) {
              return GET(urls[0]);
          }
          // onPostExecute displays the results of the AsyncTask.
          @Override
          protected void onPostExecute(final String result) {
  
             final  String[] cevaplar = new String[20];
              final JSONArray[] jsonarray = {null};
              final String[] soru1 = {null};
              final String[] id_soru1 = {null};
              final int[] y = {0};
  
  
              final String[] cvp = new String[24];
  
  
                      try {
                          final int[] t = { 0 };
                          jsonarray[0] = new JSONArray(result);
  
  
                          final JSONObject obj1 = jsonarray[0].getJSONObject(t[0]);
                          id_soru1[0] = obj1.getString("id_soru");
                          soru1[0] = obj1.getString("baslik_soru");
  
  
                          tv_soruNum.setText(id_soru1[0]);
                          tv_soru.setText(soru1[0]);
  
  
  
                          for (int k = 0; k &lt; 4; k++) {
                              cvp[k] = obj1.getString("icerik_cevap");
                             if(k == 0){
                                 rb_a.setText(cvp[k]);
                             }else if(k == 1) {
                                 rb_b.setText(cvp[k]);
                             }else if(k == 2){
                                 rb_c.setText(cvp[k]);
                             }else if(k == 3){
                                rb_d.setText(cvp[k]);
                             }
  
                          }
  
                          if ( rb_a.isSelected()){
                              cvp[y[0]]="A";
  
                          }
                          else if( rb_b.isSelected()){
                              cvp[y[0]] ="B";
                             }
                          else if( rb_c.isSelected()){
                              cvp[y[0]]="C";
                            }
                          else if( rb_d.isSelected()){
                              cvp[y[0]]="D";
                              }
                          else {
                              rb_a.setChecked(false);
                              rb_b.setChecked(false);
                              rb_c.setChecked(false);
                              rb_d.setChecked(false);
                          }
  
  
                          final JSONArray finalJsonarray = jsonarray[0];
                          btn_sonrakiSoru.setOnClickListener(new View.OnClickListener() {
                              @Override
                              public void onClick(View v) {
                                  try{
                                  t[0]+=4;
                                      y[0] +=1;
  
                                      btn_oncekiSoru.setEnabled(true);
                                  JSONObject obj2 = finalJsonarray.getJSONObject(t[0]);
                                  id_soru1[0] = obj2.getString("id_soru");
                                  soru1[0] = obj2.getString("baslik_soru");
  
  
                                  tv_soruNum.setText(id_soru1[0]);
                                  tv_soru.setText(soru1[0]);
                                      for (int k = 0; k &lt; 4; k++) {
                                          cvp[k] = obj2.getString("icerik_cevap");
                                          if (k == 0) {
                                              rb_a.setText(cvp[k]);
                                          } else if (k == 1) {
                                              rb_b.setText(cvp[k]);
                                          } else if (k == 2) {
                                              rb_c.setText(cvp[k]);
                                          } else if (k == 3) {
                                              rb_d.setText(cvp[k]);
                                          }
                                      }
  
                                      if ( rb_a.isSelected()){
                                          cvp[y[0]]="A";
  
                                      }
                                      else if( rb_b.isSelected()){
                                          cvp[y[0]] ="B";
                                       }
                                      else if( rb_c.isSelected()){
                                          cvp[y[0]]="C";
                                          }
                                      else if( rb_d.isSelected()){
                                          cvp[y[0]]="D";
                                         }
                                      else {
                                          rb_a.setChecked(false);
                                          rb_b.setChecked(false);
                                          rb_c.setChecked(false);
                                          rb_d.setChecked(false);
                                      }
  
  
                                      int j=t[0] + 4;
                                      if(j == finalJsonarray.length()){
                                          btn_sonrakiSoru.setEnabled(false);
                                          btn_sonrakiSoru.setVisibility(View.INVISIBLE);
                                          btn_kaydet.setVisibility(View.VISIBLE);
                                          btn_kaydet.setEnabled(true);
  
                                          btn_kaydet.setOnClickListener(new View.OnClickListener() {
                                              @Override
                                              public void onClick(View v) {
  
                                                  btn_oncekiSoru.setEnabled(false);
  
  
                                              }
                                          });
                                      }
  
  
                                  }catch (JSONException e) {
                                      e.printStackTrace();
                                  }
  
                              }
                          });
  
  
  
                          btn_oncekiSoru.setOnClickListener(new View.OnClickListener() {
                              @Override
                              public void onClick(View v) {
                                  t[0]-=4;
  
  
                                  JSONObject obj2 = null;
                                  try {
                                      obj2 = finalJsonarray.getJSONObject(t[0]);
                                      id_soru1[0] = obj2.getString("id_soru");
                                      soru1[0] = obj2.getString("baslik_soru");
  
  
                                      tv_soruNum.setText(id_soru1[0]);
                                      tv_soru.setText(soru1[0]);
  
                                      for (int k = 0; k &lt;4; k++) {
                                          cvp[k] = obj2.getString("icerik_cevap");
                                          if (k == 0) {
                                              rb_a.setText(cvp[k]);
                                          } else if (k == 1) {
                                              rb_b.setText(cvp[k]);
                                          } else if (k == 2) {
                                              rb_c.setText(cvp[k]);
                                          } else if (k == 3) {
                                              rb_d.setText(cvp[k]);
                                          }
                                      }
  
                                      if ( rb_a.isSelected()){
                                          cvp[y[0]]="A";
  
                                      }
                                      else if( rb_b.isSelected()){
                                          cvp[y[0]] ="B";
                                       }
                                      else if( rb_c.isSelected()){
                                          cvp[y[0]]="C";
                                       }
                                      else if( rb_d.isSelected()){
                                          cvp[y[0]]="D";
                                         }
                                      else {
                                          rb_a.setChecked(false);
                                          rb_b.setChecked(false);
                                          rb_c.setChecked(false);
                                          rb_d.setChecked(false);
                                      }
  
                                      if( t[0] == 0 ){
                                          btn_oncekiSoru.setEnabled(false);
                                      }
                                  } catch (JSONException e) {
                                      e.printStackTrace();
                                  }
  
                              }
                          });
  
  
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
  
          }
  
  
      public static String GET(String url){
          InputStream inputStream = null;
          String result = "";
          try {
              // create HttpClient
              HttpClient httpclient = new DefaultHttpClient();
              // make GET request to the given URL
              HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
              // receive response as inputStream
              inputStream = httpResponse.getEntity().getContent();
              // convert inputstream to string
              if(inputStream != null)
                  result = convertInputStreamToString(inputStream);
              else
                  result = "Did not work!";
          } catch (Exception e) {
              Log.d("InputStream", e.getLocalizedMessage());
          }
          return result;
      }
  
      private static String convertInputStreamToString(InputStream inputStream) throws IOException {
          BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
          String line = "";
          String result = "";
          while((line = bufferedReader.readLine()) != null)
              result += line;
          inputStream.close();
          return result;
      }
  
  
      }
  </code></pre>
  
  <p>and my .xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#ffffff"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:id="@+id/tv_soruNum"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:id="@+id/tv_soru"
          android:layout_alignParentTop="true"
          android:layout_toRightOf="@+id/tv_soruNum"
          android:layout_toEndOf="@+id/tv_soruNum"
          android:layout_marginLeft="48dp"
          android:layout_marginStart="48dp" /&gt;
  
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="3dp"
          android:layout_below="@+id/tv_soru"
          android:id="@+id/view"
          android:layout_marginBottom="25dp"
          android:layout_marginTop="35dp"
          android:background="#000000" /&gt;
  
      &lt;RadioButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/rb_cevapa"
          android:layout_below="@+id/view"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:checked="false" /&gt;
  
      &lt;RadioButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/rb_cevapb"
          android:layout_below="@+id/rb_cevapa"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="52dp"
          android:checked="false" /&gt;
  
      &lt;RadioButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/rb_cevapc"
          android:layout_below="@+id/rb_cevapb"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="68dp"
          android:checked="false" /&gt;
  
      &lt;RadioButton
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/rb_cevapd"
          android:layout_below="@+id/rb_cevapc"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="68dp"
          android:checked="false" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Oncekı"
          android:id="@+id/btn_oncekiSoru"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;Button
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/btn_sonrakiSoru"
          android:layout_alignTop="@+id/btn_oncekiSoru"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:text="Sonraki" /&gt;
  
      &lt;Button
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Kaydet"
          android:id="@+id/btn_kaydet"
          android:layout_alignTop="@+id/btn_sonrakiSoru"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true" /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xKSJC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xKSJC.jpg" alt="enter image description here"></a></p>
  
  <p>Thanks for help me..</p>