Well, the resource stuff isn't a "Java" thing, it's an Android thing.
Basically if you put a layout xml file in res/layout, you reference it
by filename when you call setContentView. For instance, if you have
res/layout/my_fancy_layout.xml, you make a call to
setContentView(R.layout.my_fancy_layout).

But, it sounds like you have a main.xml in that directory and using it
correctly with setContentView. The layout xml looks valid for the m5
sdk. Are you using m5 or m3? Also, if you are using eclipse, it should
tell you if theres a problem in the xml file itself when you open the
file. That might give some insight.

On Apr 22, 10:14 am, Kastagire <[EMAIL PROTECTED]> wrote:
> Thank for the info Tatsu... The file I am trying to import is
> main.xml, and is located in Res->Layout. I just labeled the XML
> DroidDraw to pretty much say it was from DroidDraw.. I wasn't awake
> yet when I put that in there I guess, lol.
>
> I am not quite following the part about the res filename. Pardon my
> ignorance, I have only been doing JAVA stuff for a few days, and I am
> not very well versed in it. Would you be able to be a little more
> detailed with that explanation?
>
> On Apr 22, 9:52 am, Tatsu <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > It seems that res filename must contain only [a-z0-9_-.]. (It is
> > possibly undocumented issue.)
>
> > Change your layout filename from DroidDraw.xml to droiddraw.xml or
> > simply main.xml, and hand same name to setContentView().
>
> > Best Regards,
> >  Tatsu
> >  http://www.tatsu.com
>
> > On Apr 22, 9:31 pm, Kastagire <[EMAIL PROTECTED]> wrote:
>
> > > 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 android-beginners@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to