Hi,

I am new to Android development and I am currently working through a
tutorial but have already run into a brick wall. I am trying to handle
a simple button click following some sample code but can't get it to
work. I do not get any errors, but the click does not register on the
emulator. I have set breakpoints and confirmed that the handler never
gets executed. I have attached the complete code below. Any help would
be appreciated.

package com.test.HelloWorld;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class mainPage extends Activity {

    TextView dollars;
    TextView euros;
    TextView debug;
    RadioButton dtoe;
    RadioButton etod;
    Button convert;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        dollars = (TextView)this.findViewById(R.id.dollars);
        euros = (TextView)this.findViewById(R.id.euros);
        debug = (TextView)this.findViewById(R.id.Debug);
        dtoe = (RadioButton)this.findViewById(R.id.dtoe);
        etod = (RadioButton)this.findViewById(R.id.etod);

        dtoe.setChecked(true);

        debug.setText("Program Started..");

        convert = (Button)this.findViewById(R.id.convert);
        convert.setOnClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View v) {
                                // TODO Auto-generated method stub
                                if (dtoe.isChecked())
                        {
                                convertDollarsToEuros();
                        }

                        if (etod.isChecked())
                        {
                                convertEurosToDollars();
                        }
                        }
                });
       }

    protected void convertDollarsToEuros()
    {
        double val = Double.parseDouble(dollars.getText().toString());
        euros.setText(Double.toString(val*0.67));
        debug.setText(euros.getText());

    }

    protected void convertEurosToDollars()
    {
        double val = Double.parseDouble(euros.getText().toString());
        dollars.setText(Double.toString(val/0.67));
    }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to