gpt4 book ai didi

nativescript - 在 Android 上的 NativeScript 中,如何防止 SearchBar 获得对页面加载的关注?

转载 作者:行者123 更新时间:2023-12-04 16:28:47 24 4
gpt4 key购买 nike

我在 ScrollView 中有一个 SeachBar。在iOS中一切都很好。在 Android 上,ScrollView 会自动滚动到 SearchBar,为其添加焦点并显示软键盘。我可以通过添加 android:windowSoftInputMode="stateHidden" 来隐藏软键盘作为 AndroidManifest.xml 文件中的一个事件,但我不知道如何阻止焦点(以及自动滚动)。任何帮助将非常感激。

最佳答案

使用 Angular2 :

应用程序/my.component.html

<StackLayout (loaded)="onSearchLayoutLoaded($event)">
<SearchBar hint="search here" (loaded)="onSearchBarLoaded($event)">
</SearchBar>
</StackLayout>

应用程序/my.component.ts
    onSearchLayoutLoaded(event) {
if (event.object.android) {
event.object.android.setFocusableInTouchMode(true);
}
}

onSearchBarLoaded(event) {
if (event.object.android) {
event.object.android.clearFocus();
}
}

这消除了不必要的使用 template reference variables .

关于nativescript - 在 Android 上的 NativeScript 中,如何防止 SearchBar 获得对页面加载的关注?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35868208/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com