android 在 fragment 中隐藏标题

标签 android android-fragments

我已经开始在 fragment 中工作。我试图在 fragment 中隐藏 titleBar,但我有这个 Log-cat 错误

android fragment requestfeature must be called before adding content

这是一个来源

public class SendItemsFragment extends Fragment {

Button b1;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE);


    View rootView = inflater.inflate(R.layout.send_items, container, false);



    return rootView;
    }

}

最佳答案

这对我有用:

隐藏操作栏

((AppCompatActivity) getActivity()).getSupportActionBar().hide();

关于android 在 fragment 中隐藏标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24183609/

相关文章:

java - 安卓工作室 : "No JVM installation found. Please install a 32-bit JDK "

android - 设置警报管理器正在创建我的主要 Activity 的 2 个实例

java - 安卓/Java : why does my ConstraintLayout leak?

android - 你能在替换时给 fragment 额外的东西吗?

android - 如何从 ViewPager 中的不同 fragment 制作工具栏中的单击按钮?

android - 如何从表面 View 创建和保存屏幕截图?

android - 如何将 viewPager 作为标题添加到 ListView

android - 我怎样才能开始新的 Activity 作为从中心扩大的圆圈

android - View Pager Crash Null Pointer Exception 由于导航回旧 fragment - Android

android - 在应用程序打开时加载所有 fragment