Hey All,
I have been working on the DroidDraw currency conversion calculator to try to get the hang of Android, but I keep getting a weird error when it goes to display on the emulator. The error states:
Application Error: com.android.CurrencyConverter
An error has occurred in com. android.CurrencyConverter. Unable to instantiate activity component info{com. android.CurrencyConverter/com.android.CurrencyConverter.currencycalc} java.land.Class not found exception:
I have attached a screenshot of the error as well.
The Code is as follows:
package com.android.CurrencyConverter;
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;
import java.lang.*;
public class CurrencyConverter extends Activity implements OnClickListener {
TextView dollars;
TextView euros;
RadioButton dtoe;
RadioButton etod;
Button convert;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.main);
dollars = (TextView)this.findViewById(R.id.dollars);
euros = (TextView)this.findViewById(R.id.widget161);
dtoe = (RadioButton)this.findViewById(R.id.dtoe);
dtoe.setChecked(true);
etod = (RadioButton)this.findViewById(R.id.etoe);
convert = (Button)this.findViewById(R.id.widget36);
convert.setOnClickListener(this);
}
public void onClick(View v) {
if (dtoe.equals(true)) {
convertDollarsToEuros();
}
if (etod.equals(true)) {
convertEurosToDollars();
}
}
public 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));
}
public 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));
}
}
The XML code is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget156"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/widget37"
android:layout_width="wrap_content"
android:layout_height="-119px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
>
</LinearLayout>
<LinearLayout
android:id="@+id/widget157"
android:layout_width="200px"
android:layout_height="225px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
>
<TextView
android:id="@+id/widget158"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dollars"
android:textStyle="bold"
>
</TextView>
<EditText
android:id="@+id/dollars"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="EditText"
android:textSize="18sp"
>
</EditText>
Any help you can give me to figure this out will be appreciated!
-Greg


