Search code examples
javaandroidxmlandroid-inflateandroid-tabbed-activity

I have multiple layout files but the app is only recognising 1?


I am trying to create tabs in an Android Studio project (I am following an online tutorial), and I have created fragment1/2/3_layout.xml files by creating the 1st one and then copy/pasting, but in my fragment1/2/3.java files it is only recognising/resolving the 1st one (fragment1_layout)?

I have tried creating a new layout file by right-clicking>new layout file etc etc but it still does not show up or get recognised when I try to pass it into the inflator.

I have tried to clean and rebuild but that also doesn't work, and apart from the error message that comes up when I try to pass one of the other XML files, there are no other errors (that pop up) in the code.

I am a novice coder and I hope I am not making some stupid mistake, but at the same time I really do hope I am just making a stupid mistake because this is driving me insane.

public class fragment1 extends Fragment {

   @Nullable
   @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,   
         @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment1_layout,container,false);
  }
}

List of layout files

Error message

Auto-fill suggestion (not showing all layout files)


Solution

  • After some digging I found a comment somewhere on here that mentioned updating the SDK, so that is what I did and seems to be working now. Other XML files are now available to be referenced