我想在Titanium appcelerator中使用xml添加一个片段,但是我得到了错误提示。
错误:二进制XML文件第6行:二进制XML文件第6行:膨胀类片段时出错
我已经在 platform / android / res / layout 中创建了一个xml文件,如超级循环指南中所述
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linear">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frame">
<fragment
android:id="@+id/player_fragment"
android:name="com.aol.mobile.sdk.player.view.PlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
错误
Error - [ERROR] : TiExceptionHandler: (main) [117,396] /hyperloop/android.view.LayoutInflater.js:390
[ERROR] : TiExceptionHandler: var result = this.$native.callNativeFunction({
[ERROR] : TiExceptionHandler: ^
[ERROR] : TiExceptionHandler: Error: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment
[ERROR] : TiExceptionHandler: at LayoutInflater.inflate (/hyperloop/android.view.LayoutInflater.js:390:28)
[ERROR] : TiExceptionHandler: at new Controller (/alloy/controllers/index.js:44:15)
[ERROR] : TiExceptionHandler: at Object.exports.createController (/alloy.js:339:9)
[ERROR] : TiExceptionHandler: at /app.js:59:7
[ERROR] : TiExceptionHandler: at Module._runScript (ti:/module.js:613:9)
[ERROR] : TiExceptionHandler: at Module.load (ti:/module.js:105:7)
[ERROR] : TiExceptionHandler: at Module.loadJavascriptText (ti:/module.js:457:9)
[ERROR] : TiExceptionHandler: at Module.loadAsFile (ti:/module.js:512:15)
[ERROR] : TiExceptionHandler: at Module.loadAsFileOrDirectory (ti:/module.js:429:20)
[ERROR] : TiExceptionHandler: at Module.require (ti:/module.js:256:17)
[ERROR] : TiExceptionHandler:
[ERROR] : V8Exception: Exception occurred at /hyperloop/android.view.LayoutInflater.js:390: Uncaught Error: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment
JS文件
const Context = require('android.content.Context');
const Inflater = require('android.view.LayoutInflater');
const Activity = require('android.app.Activity');
const activity = new Activity(Ti.Android.currentActivity);
const inflater = Inflater.cast(activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE));
const resID = activity.getResources().getIdentifier('floating', 'layout', activity.getPackageName());
const view = inflater.inflate(resID, null);
$.win.add(view);
$.win.open();