title: have made radio button dynamically but sometime first radio button is not able to select
body: <p>while selecting first radio button its not showing its checked.. but when i select other and after that if i select first it shows its checked.</p>
  
  <p><strong>Code :-</strong></p>
  
  <pre><code> private void Displayradiobutton(String hatchfetchnumber) {
  
      DBAdapter db = new DBAdapter(getApplicationContext());
      Log.i("test", "SETTING ADAPTER FOR DISPLAYRADIOBUTTON()");
      Cursor cr;
      cr = db.gethatchno(hatchfetchnumber);
      Log.i("test", "GET DATA FROM GETHATCHNO" + cr);
      cr.moveToFirst();
      selecthatch = cr.getInt(0);
      Log.i("test", "Step 2");
      if (selecthatch &gt;= 12) {
          down.setVisibility(View.VISIBLE);
      } else {
          down.setVisibility(View.INVISIBLE);
      }
      errortext.setVisibility(View.VISIBLE);
      radiogroup.removeAllViews();
  
      for (int i = 1; i &lt;= selecthatch; i++) {
  
          RadioButton rdbtn = new RadioButton(this);
          rdbtn.setId(i);
          rdbtn.setPadding(15, 7, 15, 7);
          rdbtn.setTextSize(20);
          rdbtn.setText("Hatch " + i);
  
          radiogroup.addView(rdbtn);
          text.setEnabled(true);
          if (selecthatch == 1) {
              rdbtn.setChecked(true);
              flag = 1;
          } else {
              flag = 0;
          }
  
      }
  
  }
  
  @Override
  public void onCheckedChanged(RadioGroup group, int checkedId) {
      flag = 1;
      errortext.setVisibility(View.INVISIBLE);
      // selectedHatch = (RadioButton) findViewById(checkedId);
  }}
  </code></pre>