“main”上发生未捕获的异常线。使用自定义搜索栏时
我已经迁移了我的本机脚本角度应用程序。 迁移后自定义搜索栏中出现问题。 迁移之前工作正常。 它显示“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论