I wanted to create a Fragment
in Android Studio, so I did the following steps:
The description said "Creates a new fragment containing a list that can optionally change to grid when on large screens."
Here's the funny part: As I was reading the code to understand how this switching is done, I could not find any code that switched XML
files or anything. The only odd thing that I found is that the XML
used for the Adapter
was called R.layout.fragment_item
, but there was no XML called like that in my layout folder.
There were 2 XML called R.layout.fragment_item_list
and R.layout.fragment_item_grid
. So I though "hey, maybe internally the framework auto decide if going for _grid
or _list
and that's why it doesn't mark R.layout.fragment_item
it as non-existent"
When I was done reading the code, I deleted both R.layout.fragment_item_list
and R.layout.fragment_item_grid
from my layout folder and guess what? R.layout.fragment_item
is NOT marked as non-existent, and there is no such file inside my Layout folder.
I already went Build > Clean and Build > Rebuild Project and it still marks it as existent. Am I missing something here? sounds like there is some basic stuff I haven't taken into account.
Just found what was going on. Inside values/refs.xml
there was <item name="fragment_item" type="layout">@layout/fragment_item_grid</item>
which should be the cause of it.
I had the same issue, I didn't understand your solution as I couldn't see refs.xml in the values folder.
For anybody out there, this is what worked for me: In Android Studio go to File -> Invalidate Caches / Restart...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With