“main”上发生未捕获的异常线。使用自定义搜索栏时

发布于 2025-01-11 00:35:48 字数 2362 浏览 0 评论 0原文

我已经迁移了我的本机脚本角度应用程序。 迁移后自定义搜索栏中出现问题。 迁移之前工作正常。 它显示“nativeView.setOnQueryTextListener(queryTextListener);”中有问题

我的自定义搜索栏:

import { SearchBar } from '@nativescript/core';

let QueryTextListener: QueryTextListener;
function initializeNativeClasses(): void {
    if (QueryTextListener) {
        return;
    }
@Interfaces([androidx.appcompat.widget.SearchView.OnQueryTextListener])
class CustomSearchBarImplementation extends java.lang.Object implements androidx.appcompat.widget.SearchView.OnQueryTextListener
{
    public thenewText="";
    constructor(private owner: CustomSearchBar) {
        super();
        return global.__native(this);
    }
    public onQueryTextChange(text: string): boolean {
        return true;
    }    
    public onQueryTextSubmit(text: string): boolean {
        console.log("onQueryTextSubmit onsubmit called")
        const owner = this.owner;
        this.thenewText = text;
        owner.notify({
            object: owner,
            eventName: "DoneIt",
            textSequences: text,
        });
        // owner._emit("onsubMit");        
        return true;

    }


}
QueryTextListener = CustomSearchBarImplementation;

}


export class CustomSearchBar extends SearchBar
{
    nativeViewProtected: androidx.appcompat.widget.SearchView;
    public createNativeView() {
        const nativeView = new androidx.appcompat.widget.SearchView(this._context);
        nativeView.setIconified(false);
        return nativeView;
    }
    
    //Comment by naveen//
    public initNativeView(): void {
        super.initNativeView();
        const nativeView = this.nativeViewProtected;
        initializeNativeClasses();
        const queryTextListener = new QueryTextListener(this);
        nativeView.setOnQueryTextListener(queryTextListener);
        (<any>nativeView).queryTextListener = queryTextListener;
    }


}
interface QueryTextListener {
    new(owner: SearchBar): androidx.appcompat.widget.SearchView.OnQueryTextListener;
}
interface CloseListener {
    new(owner: SearchBar): androidx.appcompat.widget.SearchView.OnQueryTextListener;
}

我的错误消息:

如何解决这个问题?

I have migrating my native script angular application.
Having issue in the custom searchBar after migration.
Before migration which was working fine.
It shows like having issue in the "nativeView.setOnQueryTextListener(queryTextListener);"

my custom searchbar:

import { SearchBar } from '@nativescript/core';

let QueryTextListener: QueryTextListener;
function initializeNativeClasses(): void {
    if (QueryTextListener) {
        return;
    }
@Interfaces([androidx.appcompat.widget.SearchView.OnQueryTextListener])
class CustomSearchBarImplementation extends java.lang.Object implements androidx.appcompat.widget.SearchView.OnQueryTextListener
{
    public thenewText="";
    constructor(private owner: CustomSearchBar) {
        super();
        return global.__native(this);
    }
    public onQueryTextChange(text: string): boolean {
        return true;
    }    
    public onQueryTextSubmit(text: string): boolean {
        console.log("onQueryTextSubmit onsubmit called")
        const owner = this.owner;
        this.thenewText = text;
        owner.notify({
            object: owner,
            eventName: "DoneIt",
            textSequences: text,
        });
        // owner._emit("onsubMit");        
        return true;

    }


}
QueryTextListener = CustomSearchBarImplementation;

}


export class CustomSearchBar extends SearchBar
{
    nativeViewProtected: androidx.appcompat.widget.SearchView;
    public createNativeView() {
        const nativeView = new androidx.appcompat.widget.SearchView(this._context);
        nativeView.setIconified(false);
        return nativeView;
    }
    
    //Comment by naveen//
    public initNativeView(): void {
        super.initNativeView();
        const nativeView = this.nativeViewProtected;
        initializeNativeClasses();
        const queryTextListener = new QueryTextListener(this);
        nativeView.setOnQueryTextListener(queryTextListener);
        (<any>nativeView).queryTextListener = queryTextListener;
    }


}
interface QueryTextListener {
    new(owner: SearchBar): androidx.appcompat.widget.SearchView.OnQueryTextListener;
}
interface CloseListener {
    new(owner: SearchBar): androidx.appcompat.widget.SearchView.OnQueryTextListener;
}

my error message:

how to fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文