简体   繁体   English

即使我创建了一个带有附加 xml 布局的空白片段。 我的片段 java 不与片段布局连接

[英]even though I create a Blank Fragment with attached xml layout. my Fragment java dont connet with fragment layout

Here is the java code with error这是有错误的java代码

public class fragemnt extends Fragment {


public fragemnt() {
    // 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_fragemnt, container, false);
}

} }

here my javaFragment cannot find the Fragement_fragment layout eventhough the xml file shows in the layout direcotry这里我的 javaFragment 找不到 Fragment_fragment 布局,即使 xml 文件显示在布局目录中

heres my Xml file这是我的 Xml 文件

 <?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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=".FirstSemester.fragemnt">

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/hello_blank_fragment" />

</FrameLayout>

try to clean, the click on build.尝试清理,点击构建。 if it did not work try to invalidate cache and restart如果它不起作用尝试使缓存无效并重新启动

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM