Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio XML Layout file exist but I can't find it

I wanted to create a Fragment in Android Studio, so I did the following steps:

  1. Right click on package
  2. New -> Android (Other) -> Fragment (List)
  3. Checked both include fragment factory methods? and switch to grid view on large screens

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_gridfrom 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.

like image 675
Christopher Francisco Avatar asked Mar 27 '14 02:03

Christopher Francisco


2 Answers

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.

like image 113
Christopher Francisco Avatar answered Oct 21 '22 02:10

Christopher Francisco


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...

like image 39
Koch Avatar answered Oct 21 '22 01:10

Koch