希望这很适合您。
我的nativescript应用存在此问题,当最小化并恢复该应用时,页面内容将重新加载。
我如何才能阻止这种情况,我坚信这与我的AndroidManifest.xml有关
此问题的一个示例是
我有一个带有radlistview的页面,当我在此页面上最小化并恢复时,listivew重新加载并返回0,而不是滚动以从我最小化之前的位置继续
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
android:launchMode="singleInstance"
android:requestLegacyExternalStorage="true"
android:windowSoftInputMode="stateHidden | adjustPan">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="www.magnoliyan.com" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
Page.js
const HomeViewModel = require("./home-view-model");
exports.pageLoaded = function (args) {
const page = args.object;
const homeViewModel = new HomeViewModel();
page.bindingContext = homeViewModel;
page.bindingContext.initDataItems();
page.bindingContext.addMoreItemsFromSource(8);
statusBar.show();
}
答案 0 :(得分:0)
最后找到了问题 当应用最小化并重新打开时,将调用pageLoaded事件,
从pageLoaded更改为导航以进行修复
exports.onNavigatingTo = function (args) {
const page = args.object;
const homeViewModel = new HomeViewModel();
page.bindingContext = homeViewModel;
page.bindingContext.initDataItems();
page.bindingContext.addMoreItemsFromSource(8);
statusBar.show();
}