-1

I have 3 radio button in group and I want to call intent on click of radio button but when I clicked on radio button I got exception and I'm not able to find out what kind of exception I'm getting.

Here is my code.

public class Contentstory extends Activity {

    RadioButton Child,Adult,Animated ;
    RadioGroup radiogroup1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content);

        radiogroup1 = (RadioGroup) findViewById(R.id.radioGroup1);
        final RadioButton Child = (RadioButton)findViewById(R.id.radio0);

       radiogroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

            public void onCheckedChanged(RadioGroup group, int checkedId) {

                if (Child.isChecked()){

        Intent intent = new Intent(getApplicationContext(),StoryList.class);
        Contentstory.this.startActivity(intent);


                }


            }

        });   

https://i.stack.imgur.com/c9bqe.jpg

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Mike
  • 11
  • 1
  • 4
  • Can you explain how you know you're getting an exception without being able to see what the exception is? Maybe with a screenshot? Is this happening in the emulator or on a device? – Bill the Lizard Aug 02 '11 at 12:53

1 Answers1

0
  1. No need to call radiogroup1 = (RadioGroup) findViewById(R.id.radioGroup1);

  2. Check id of radio button correctly as your code showing no error,

  3. Post exception then i will be able to check what's going wrong with id?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Tofeeq Ahmad
  • 11,935
  • 4
  • 61
  • 87
  • Thanks Sathya for your reply, as you said that my code does not contain any error, i agreed with you. In fact my problem exist in XML file and exception showing issue in following line "Intent intent = new Intent(getApplicationContext(),StoryList.class); " but thanks again for your reply – Mike Aug 04 '11 at 05:59
  • Answer is not given by Sathya,,he just edited it,If it help you to solve your problem then accept it as a answer and up vote it – Tofeeq Ahmad Aug 04 '11 at 07:14