我試圖在一個片段內部實現CordovaWebView(2.2.0),但它試圖膨脹佈局時返回一個錯誤。CordovaWebView裏面的片段返回NullPointerException
我的XML:
<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>
我onCreateView:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.cordovawebview, container); // <--- the error occurs here!
return v;
}
錯誤:
10-25 15:52:02.839: ERROR/AndroidRuntime(2878): FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #21: Error inflating class org.apache.cordova.CordovaWebView NullPointerException CordovaWebView.java line 691
int id = getResources().getIdentifier("config", "xml", this.cordova.getActivity().getPackageName());
看來,資源是空在這裏。
我已經檢查過它,並且config.xml文件位於xml文件夾中。
我可以在FragmentActivity中實現它,但我需要它在一個片段中。
任何想法?
在此先感謝。