我正在尝试根据 this: 创建 fragment 类
他们给了你 fragment 类的代码,但我得到了
ExampleFragments.java
package com.example.learn.fragments;
public static class ExampleFragments extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.blue_pill_frag, container, false);
}
}
但是我在第 9 行遇到了一个错误,我在那里声明了类的名称。
Illegal modifier for the class ExampleFragments; only public, abstract & final are permitted
我确定这是我不理解的基本内容,谢谢。
最佳答案
你不能有一个static
顶级类。变化
public static class ExampleFragments extends Fragment {
到
public class ExampleFragments extends Fragment {
关于java - 尝试创建 fragment 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11614006/