Issues with Selecting two RadioGroups


Last Updated:

  1. diltuff

    diltuff New Member This Topic's Starter

    Joined:
    Sep 23, 2010
    Messages:
    1
    Likes Received:
    0
    Hi everyone, I'm a new here but I thought that maybe someone would have the answer to my question.

    I'm building my first program in android and while I'm fairly fluent in Java, I seem to be having some issues. What I'm trying to do is build a temperature conversion program by using radio buttons to select a "from temperature" and "to temperature" option which will then take user input, do the calculations, and then output an answer.

    My issue right now is that while my input is working great, my if statements don't pickup the selection of two radio buttons from two different RadioGroups. Here's what I have so far:

    public void onCheckedChanged(RadioGroup group, int checkedId) {

    String sInput = et.getText().toString();
    Double Input = Double.parseDouble(sInput);
    temp = Input;

    if(checkedId == R.id.FK && checkedId == R.id.TK)
    {
    output = temp;
    tv.setText(String.valueOf(output));

    }

    FK and TK are my "from kelvin" and "to kelvin" radio buttons. The "from kelvin" button is included in the "FromTemp" radiogroup and the "to kelvin" button is included in the "ToTemp" radiogroup. "tv" is my TextView output and "et" is my EditText input.

    If I click both the FK and TK buttons when i run the program, the if statement never triggers and the TextView never outputs anything. If I change the if statement to only check for the FK button, it works just fine but it doesn't work the way i need it.

    Is there anyway I can check if both the FK and TK Radio buttons are selected?

    Any help is extremely appreciated.


    Dilan
     

    Advertisement

Share This Page

Loading...