Hey all,
I have been fiddling around with Android for the past couple of days,
and I was working through the tutorials and sample code. Yesterday, I
made an interface with DroidDraw, which generates XML to make the GUI.
As far as I can see, everything is in order, but I have an error when
it goes to pull the XML from the layout folder. It says that
R.layout.main cannot be resolved, and thus all subsequent links to the
XML get a similar error. I have been plugging away on this problem for
a couple of hours, but cannot get it to work. I checked the forums
already, and someone mentioned that the version of DroidDraw may not
be compatible with the new SDK, but I checked what was posted, and it
seemed to work fine. Below is the JAVA code, and then the XML from
Droid Draw.. any help would be appreciated!!!
Thanks!
package com.android.androidtake2;
import android.R;
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 androidtake2 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.euros);
dtoe = (RadioButton)this.findViewById(R.id.dtoe);
dtoe.setChecked(true);
etod = (RadioButton)this.findViewById(R.id.etod);
convert = (Button)this.findViewById(R.id.convert);
convert.setOnClickListener(this);
}
public void onClick(View v) {
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));
}
protected void convertEurosToDollars() {
double val = Double.parseDouble(euros.getText().toString());
dollars.setText(Double.toString(val/0.67));
}
}
"DroidDraw" XML-
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget63"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/widget96"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_x="91px"
android:layout_y="0px"
>
<EditText
android:id="@+id/viewdol"
android:layout_width="100 px"
android:layout_height="wrap_content"
android:text="Dollars"
android:textSize="18sp"
android:textStyle="bold"
>
</EditText>
<TextView
android:id="@+id/dollars"
android:layout_width="100 px"
android:layout_height="wrap_content"
android:background="@drawable/lightgray"
>
</TextView>
<EditText
android:id="@+id/vieweuro"
android:layout_width="100 px"
android:layout_height="wrap_content"
android:text="Euros"
android:textSize="18sp"
android:textStyle="bold"
>
</EditText>
<TextView
android:id="@+id/euros"
android:layout_width="100 px"
android:layout_height="wrap_content"
android:background="@drawable/lightgray"
>
</TextView>
<RadioButton
android:id="@+id/dtoe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dollars to Euros"
>
</RadioButton>
<RadioButton
android:id="@+id/etod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Euros to Dollars"
>
</RadioButton>
</LinearLayout>
<Button
android:id="@+id/convert"
android:layout_width="200px"
android:layout_height="wrap_content"
android:background="@drawable/green"
android:text="Convert"
android:layout_x="60px"
android:layout_y="229px"
>
</Button>
</AbsoluteLayout>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---