Android 片段内的CordovaWebView返回NullPointerException
我试图在一个片段中实现CordovaWebView(2.2.0),但在尝试扩大布局时返回了一个错误 我的xml:Android 片段内的CordovaWebView返回NullPointerException,android,android-fragments,android-webview,cordova-2.0.0,Android,Android Fragments,Android Webview,Cordova 2.0.0,我试图在一个片段中实现CordovaWebView(2.2.0),但在尝试扩大布局时返回了一个错误 我的xml: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <org.apache.cordova.C
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.apache.cordova.CordovaWebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id = "@+id/mainView"/>
</FrameLayout>
这里的资源似乎为空
我已经检查过了,config.xml文件在xml文件夹中
我可以在片段活动中实现它,但我需要在片段中实现它
有什么想法吗
提前感谢。@Override
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.cordovawebview, container, false); // <--- add false parameter
CordovaWebView webView = (CordovaWebView)v.findViewById(R.id.mainView);
return v;
}
CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态){
视图v=充气机。充气(R.layout.cordovawebview,container,false);//需要在碎片所在的活动上以及碎片本身上创建cordovawebview。您可以创建自己的ContextWrapper,并将其提供给充气机,以便为您处理此操作
以下是关于如何做到这一点的分步指南:
int id = getResources().getIdentifier("config", "xml", this.cordova.getActivity().getPackageName());
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.cordovawebview, container, false); // <--- add false parameter
CordovaWebView webView = (CordovaWebView)v.findViewById(R.id.mainView);
return v;
}