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;
}
}
我使用的是webView,类扩展自Fragment。我如何在这里使用getWindow()?
答案 0 :(得分:69)
您可以使用getActivity().getWindow()
此getActivity()
将返回此片段当前与之关联的活动。
答案 1 :(得分:0)
来自Activity
getWindow().setStatusBarColor(getResources().getColor(R.color.black));
来自Fragment
requireActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.black));