2016-12-16 34 views
4

我有片段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; 


    } 

} 
+0

F你正在使用AppCompatActivity(你應該),那麼這是對我工作的解決方案:。 ((AppCompatActivity)getActivity())getSupportActionBar()隱藏(); –

+0

檢查一次aboveline –

回答

2

我有同樣的問題,正在尋找答案。並得到它!

這是它。希望這將有助於:

// 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();