gpt4 book ai didi

java - 尝试创建 fragment 类

转载 作者:行者123 更新时间:2023-11-29 08:05:23 24 4
gpt4 key购买 nike

我正在尝试根据 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com