ERROR... ( Problem mit RadioButton)

L

Leon F.

Neues Mitglied
0
java.lang.ClassCastException: android.widget.RadioButton cannot be cast to android.view.ViewGroup

Diesen Error erhalte ich bei meiner xml File!
meine Activity sieht so aus:
Code:
package org.app.box;

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 dollareurocon extends Activity implements OnClickListener {
	TextView dollars;
	TextView euros;
	RadioButton dollartoeuro;
    RadioButton eurotodollar;
	Button convert;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.dollartoeuroconv);
        
        dollars = (TextView)this.findViewById(R.id.dollar);
        euros = (TextView)this.findViewById(R.id.euro);
        
        dollartoeuro = (RadioButton)this.findViewById(R.id.dollartoeuro);
        dollartoeuro.setChecked(true);
        eurotodollar = (RadioButton)this.findViewById(R.id.eurotodollar);
        eurotodollar.setChecked(true);
        
        convert = (Button)this.findViewById(R.id.convert);
        convert.setOnClickListener(this);
    }
    
	public void onClick(View v) {
		if (dollartoeuro.isChecked()) {
			convertDollarsToEuros();
		}
		if (eurotodollar.isChecked()) {
			convertEurosToDollars();
		}
	}
	
	protected void convertDollarsToEuros() {
		double val = Double.parseDouble(dollars.getText().toString());
		// in a real app, we'd get this off the 'net
		euros.setText(Double.toString(val*0.67));
	}
	
	protected void convertEurosToDollars() {
		double val = Double.parseDouble(euros.getText().toString());
		// in a real app, we'd get this off the 'net
		dollars.setText(Double.toString(val/0.67));
	}
}
 

Ähnliche Themen

M
  • myoggradio
Antworten
1
Aufrufe
760
myoggradio
M
S
Antworten
4
Aufrufe
956
Sempervivum
S
B
Antworten
4
Aufrufe
433
bb321
B
Zurück
Oben Unten