title: check if the right radioButton is checked and calculate the score
body: <p>i have an android application that display a flag and group of radio buttons  that each time the user check any radio button the application will  display a button that allow to go to the next page using intent .</p>
  
  <p>what i need is that each time the user check the right answer the system must calculate its score until the application finish .
  the score will start by 0/0 and will finish after four rounds.</p>
  
  <p><strong>for now i need just to display the score of the user in the second page</strong> </p>
  
  <p>i will appreciate any help </p>
  
  <h1>MainActivity.java</h1>
  
  <pre><code>package com.devleb.flagology;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  import android.widget.RadioGroup.OnCheckedChangeListener;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
  
      Button btnS;
      RadioGroup rdgS;
      RadioButton rdS1, rdS2, rdS3, rdS4;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          rdgS = (RadioGroup) findViewById(R.id.rdg1);
          rdgS.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  
              @Override
              public void onCheckedChanged(RadioGroup group, int checkedId) {
                  // TODO Auto-generated method stub
                   if(rdS1.isChecked()||rdS2.isChecked()||rdS3.isChecked()||rdS4.isChecked()){
                       btnS.setVisibility(View.VISIBLE);
  
                   }
              }
          });
  
          rdS1 = (RadioButton) findViewById(R.id.rd_s1);
          rdS2 = (RadioButton) findViewById(R.id.rd_s2);
          rdS3 = (RadioButton) findViewById(R.id.rd_s3);
          rdS4 = (RadioButton) findViewById(R.id.rd_s4);
  
          btnS = (Button) findViewById(R.id.btn_s);
          btnS.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  String input;
                  String result = null;
                  Double dbl;
  
                  Intent i = new Intent(MainActivity.this, SecondActivity.class);
                 switch (v.getId()) {
              case R.id.rd_s1:
                  input = rdS1.getText().toString();
                  dbl  = Double.parseDouble(input);
  
                  i.putExtra("score", 0);
                  break;
              case R.id.rd_s2:
                  i.putExtra("score", 0);
                  break;
              case R.id.rd_s3:
                  i.putExtra("score", 25);
                  break;
              case R.id.rd_s4:
                  i.putExtra("score", 0);
                  break;
  
              default:
                  break;
              }
                  startActivity(i);
  
              }
          });
  
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // TODO Auto-generated method stub
          switch (item.getItemId()) {
          case R.id.hint_icon:
              ShowAlertDialog();
              break;
          case R.id.about_icon:
              Toast.makeText(this, "developed by Georges Matta",
                      Toast.LENGTH_SHORT).show();
          default:
              break;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public void ShowAlertDialog() {
  
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setTitle("Hint")
                  .setMessage("The famouse sport is Bullfighting")
                  .setCancelable(false)
                  .setNegativeButton("OK", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          dialog.cancel();
                      }
                  });
          AlertDialog alert = builder.create();
          alert.show();
      }
  
  }
  </code></pre>
  
  <h1>edited code</h1>
  
  <pre><code>rdS1 = (RadioButton) findViewById(R.id.rd_s1);
          rdS2 = (RadioButton) findViewById(R.id.rd_s2);
          rdS3 = (RadioButton) findViewById(R.id.rd_s3);
          rdS4 = (RadioButton) findViewById(R.id.rd_s4);
  
          btnS = (Button) findViewById(R.id.btn_s);
          btnS.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  String input;
                  String result = null;
                  Double dbl;
  
                  Intent i = new Intent(MainActivity.this, SecondActivity.class);
                  switch (rdgS.getCheckedRadioButtonId()) {
                  case R.id.rd_s1:
                      input = rdS1.getText().toString();
                      dbl = Double.parseDouble(input);
                      result = String.valueOf(dbl);
  
                      i.putExtra("score", result);
                      break;
  </code></pre>
  
  <h1>activity_main.xml</h1>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/background"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="34dp"
          android:src="@drawable/spanish" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/imageView1"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:text="Gess the Country of the flag"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:textColor="#CCFF99" /&gt;
  
      &lt;RadioGroup
          android:id="@+id/rdg1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/imageView1" &gt;
  
          &lt;RadioButton
              android:id="@+id/rd_s1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:checked="true"
              android:text="Egypt"
              android:textColor="#CCFF99" /&gt;
  
          &lt;RadioButton
              android:id="@+id/rd_s2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="China"
              android:textColor="#CCFF99" /&gt;
  
          &lt;RadioButton
              android:id="@+id/rd_s3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Spanish"
              android:textColor="#CCFF99" /&gt;
  
          &lt;RadioButton
              android:id="@+id/rd_s4"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignRight="@+id/radioGroup1"
              android:layout_below="@+id/radioGroup1"
              android:text="Italy"
              android:textColor="#CCFF99" /&gt;
      &lt;/RadioGroup&gt;
  
      &lt;Button
          android:id="@+id/btn_s"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignRight="@+id/rdg1"
          android:layout_below="@+id/rdg1"
          android:text="Next"
          android:visibility="invisible" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <h1>SecondActivity.java</h1>
  
  <pre><code>package com.devleb.flagology;
  
  
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.widget.TextView;
  
  public class SecondActivity extends Activity {
  
      TextView txt_result;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_second);
  
          txt_result = (TextView) findViewById(R.id.txtResult);
  
          Bundle extras = getIntent().getExtras();
          if (extras != null) {
              String value = extras.getString("score");
              txt_result.setText(value);
          }
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.second, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <h1>activity_second.xml</h1>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".SecondActivity" &gt;
  
      &lt;TextView
          android:id="@+id/txtResult"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>