Hi, I'm a beginner android developer, and I've only been coding for a
few months. I'm testing some layouts in a project using eclipse, and
I'm following the guidelines from a textbook (beginning android 2.0)
and I'm getting some rather perplexing errors. The first error is in
my main.xml. my code is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/icon"
android:padding="2dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ok"
/>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
/>
</LinearLayout>

everything seems to work other than this line under ImageView:
android:src="@drawable/ok"

I'm not entirely sure what this means, but the error says:
Error:No resource found that matches the given name (at 'src' with
value '@drawable/ok').

Seeing as I don't really understand what I'm supposed to be
referencing, so I don't know where to begin fixing it.

Secondly, I'm getting two similar errors concerning how to create
fields in R.Java.

My code for Layout_Testing.java (my main .java file) is as follows:

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Layout_Testing extends ListActivity {
        private TextView selection;
        private static final String[] items={"lorem", "ipsum", "dolor",
        "sit", "amet",
        "consectetuer", "adipiscing", "elit", "morbi", "vel",
        "ligula", "vitae", "arcu", "aliquet", "mollis",
        "etiam", "vel", "erat", "placerat", "ante",
        "porttitor", "sodales", "pellentesque", "augue", "purus"};
        @Override
        public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        setListAdapter(new ArrayAdapter<String>(this,
        R.layout.row, R.id.label,
        items));
        selection=(TextView)findViewById(R.id.selection);
        }
        public void onListItemClick(ListView parent, View v,
        int position, long id) {
        selection.setText(items[position]);
        }
        }

everything works up until I try to set the list adapter
(setListAdapter):

setListAdapter(new ArrayAdapter<String>(this,
        R.layout.row, R.id.label,
        items));
        selection=(TextView)findViewById(R.id.selection);
        }

The error I'm getting says that they can't be resolved, so I attempted
to create a new field in R.Java. But, seeing as R.Java is derived, I
can't edit it. It just reverts back to before my edits. I'm really
confused about this and I figured this was the place to go for help.
Thanks for reading this, and if you have any suggestions, please email
me or respond!

Thanks,
James

-- 
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