I am trying to create a blank fragment. But as soon as i create a fragment by right clicking on my package and choosing Fragment>Blank Fragment and create, the fragment inflater in the Fragment.java turns red on the Fragment Layout name and says "cannot resolve symbol" . What am i doing wrong ?
here is the code..
GroupsFragment.java
package com.passengerearth.chatme;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
*/
public class GroupsFragment extends Fragment {
public GroupsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_groups, container, false);
}
}
fragment_groups.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GroupsFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Groups Fragment"
android:layout_centerInParent="true"
android:textSize="26sp"
android:textStyle="bold" />
</RelativeLayout>