I have created a simple ListActivity and a custom List item called people_list_row.xml
for the same ListView.
I am using a custom Array adqapter peopleCustomArrayAdapter.java
. Inside this custom array adapter Eclipse is throwing the error "people_list_row cannot be resolved or is not a field". Though layout people_list_row present inside R.java
There are no errors. I tried to Clean, Build the project still no luck.
//Inside Custom Array Adapter
public class peopleCustomArrayAdapter extends ArrayAdapter<String> implements OnClickListener{
String[] values;
public peopleCustomArrayAdapter(Context context,String[] values) {
super(context,R.layout.people_list_row1,values);
this.values=values;
}
}
<!-- people_list_row.xml -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:background="#035633"
android:orientation="vertical">
<TextView android:id="@+id/textName" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="TextView" />
</LinearLayout>
</RelativeLayout>
Since an adapter (ArrayAdapter
) class doesn't implicitly import the resources, you have import them manually:
import com.example.package.R;
You wouldn't need to do that in e.g. a class that extends Activity
.