Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Fragment and getWindow()

public class AircraftFragmentTab extends Fragment{
      private String ac;
      
      public AircraftFragmentTab(String AC){
          ac = AC;
         
      }
         @Override
         public View onCreateView(LayoutInflater inflater, ViewGroup container,
         Bundle savedInstanceState)
         {
             View aircraftView = inflater.inflate(R.layout.acdetails, container, false);
             
             ??? getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
              WebView wv = (WebView) aircraftView.findViewById(R.id.webac);
              wv.getSettings().setJavaScriptEnabled(true);
              wv.loadUrl("http://ABCD/ACInfo.aspx?AC=" + ac);
              
             return aircraftView;
         }
}

I am using a webView and class extends from Fragment. How can I use getWindow() here ?

like image 516
user533844 Avatar asked Sep 29 '11 17:09

user533844


2 Answers

you can use getActivity().getWindow()
this getActivity() will Return the Activity this fragment is currently associated with.

like image 122
Labeeb Panampullan Avatar answered Nov 09 '22 10:11

Labeeb Panampullan


Example from Activity

getWindow().setStatusBarColor(getResources().getColor(R.color.black));

Example from Fragment

requireActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.black));
like image 7
Olek L. Avatar answered Nov 09 '22 11:11

Olek L.