有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在特定片段中隐藏动作栏

我有片段A,B,C,D。我想把动作条隐藏在片段D中

我试过getActivity().getActionBar().hide();但没有成功

public class Profile extends Fragment {

    public Profile() {
        // Required empty public constructor
    }

    public static Profile newInstance(int instance) {
        Bundle args = new Bundle();
        args.putInt("argsInstance", instance);
        Profile profile = new Profile();
        profile.setArguments(args);
        return profile;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        getActivity().getActionBar().hide();


        // Inflate the layout for this fragment
        View profile = inflater.inflate(R.layout.fragment_profile, container, false);

        return profile;


    }

}

共 (1) 个答案

  1. # 1 楼答案

    我有同样的问题,正在寻找答案。明白了

    给你。希望这将有助于:

    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    view.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    ((AppCompatActivity)getActivity()).getSupportActionBar().hide();