Issue
My question is similar to the one linked below. XML's not being resolved/recognized by Eclipse?
I am writing code trying to use R.id. but it wont find the id's that I used.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contactlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
private class ContactListAdapter extends ArrayAdapter<Contact>{
public ContactListAdapter() {
super (MainActivity.this, R.layout.contactlayout, Contact); <!--wont find contactlayout-->
I tried to remove the "import android.R;", comment out the R lines, and build it again. The link doesn't say where to import the R from so when I do the problem comes back. Thanks for your help.
PS if I didn't do this post right please let me know. It is my first.
Solution
Your project's R
will be generated in a Java package with the same name as the Android package name in your manifest. So if the Android package name is com.example.myproject
, classes that are not in the Java package com.example.myproject
need to import com.example.myproject.R;
.
Note that your project's Android package name does not necessarily correspond to any Java package in your project. They just usually correspond because they both follow the same naming conventions.
Answered By - Kevin Krumwiede
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.