XML : Android Studio itemsAdapter and custom ListView not working

I am in Android Studio trying to implement a custom ListView. I have created an xml file called "custom_layout_rachel.xml" and have put it in my "layout" folder. This file contains the code for how I want my ListView to look.

I am trying to make the list view in my page called "activity_urgent__important.xml" to look like the one in "custom_layout_rachel.xml". In this file, I have the following code:

  <ListView        android:layout_width="wrap_content"        android:layout_height="fill_parent"        android:id="@+id/lvItems"        tools:listitem="@layout/custom_layout_rachel"   />    

In Android Studio, the custom layout is showing up, but when I run the app on my emulator, it is not there.

The java code for this activity, looks like:

  lvItems = (ListView) findViewById(R.id.lvItems);  items = new ArrayList<String>();  itemsAdapter = new ArrayAdapter<String>(this, android.R.layout.custom_layout_rachel, items);  lvItems.setAdapter(itemsAdapter);    

on the third line is where my error is.

Does anyone know why I can't do this or why I am getting an error?

Thank you!!!

No comments:

Post a Comment