我有一个LinearLayout,我想设置一个可绘制的背景
fragments.add(new FragmentTypeC().newInstance(getString(R.string.Historie6_header), R.drawable.london_old_stock_exchange));
但是它说在这一行中抛出NULLPointerException并且找不到资源。这是我的oncreateview:
View root = inflater.inflate(R.layout.fragment_type_c, container, false);
webViewHeader = (WebView) root.findViewById(R.id.header_type_c);
imageLayout = (LinearLayout) root.findViewById(R.id.layout_type_c);
webViewHeader.loadDataWithBaseURL("file:///android_asset/", loadHTLMContentHeader(header), "text/html; charset=utf-8", "utf-8", null);
webViewHeader.setBackgroundColor(0x00000000);
imageLayout.setBackground(ResourcesCompat.getDrawable(getResources(), picId, null));
return root;
}
有人知道我是如何修理它的吗?
答案 0 :(得分:0)
尝试使用此
imageLayout.setBackgroundResource(picId);