5

I'm trying to use the "tools" namespace feature in Android Studio. I'm trying to populate the ListView with dummy list items, for design purposes. The link here says the tools:listitem="@android:layout/<filename>" should do.

But for some reason, Android Studio keeps showing Layout android:<filename> does not exist. I'm trying to find a solution for it, so I don't have to run my app again and again with dummy values for testing.

I might be overlooking something very foolish, so forgive me. Here is what I have for now:

<ListView
    android:id="@+id/controllerProfiles"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="20dp"
    tools:listitem="@android:layout/profiles_list_item"/>

And I have a file profiles_list_item.xml under res/layout. Any suggestions or alternatives?

R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
Rijul
  • 515
  • 7
  • 19

2 Answers2

9

you should change the following line :

tools:listitem="@android:layout/profiles_list_item"

to this :

tools:listitem="@layout/profiles_list_item"

with @android you say that you want to use a layout from android resources but your layout is in your own project files.

Mohammad Rahchamani
  • 5,002
  • 1
  • 26
  • 36
4

tools:listitem doesn't work with ListViews in Android Studio 2.2. This is a known bug. I've tested this in Android Studio 2.3 beta 1 and it is fixed here.

You can also move from ListView to RecyclerView as this bug doesn't occur at RecyclerViews.

Cristan
  • 12,083
  • 7
  • 65
  • 69