无法创建监听器 – 传递参数有问题

huangapple go评论108阅读模式
英文:

Unable to Create Listener - Trouble Passing Arguments

问题

我正试图从我的主要活动中创建并访问Observable类中的监听器,使用以下代码:

BlePropertyObservable.getInstance().addListener(this, bleIDs)

Observable类:

public synchronized void addListener(BleEvent listener, BleEventImp eventIds[]) {
    if (null == listener || null == eventIds) return;
    for (BleEventImp id : eventIds) {
        map.put(id, listener);
    }
}

接口:

public interface BleEvent {

    void updateView(BleEventImp eventId, String action, Object... obj);
}

然而,我得到一个错误,显示:“无法使用提供的参数调用以下函数之一:”,我不确定如何解决这个问题。

如有建议,将不胜感激。

英文:

I'm attempting to create and access a listener in my Observable class from my primary activity using the following:

BlePropertyObservable.getInstance().addListener(this, bleIDs)

Observable Class:

public synchronized void addListener(BleEvent listener, BleEventImp eventIds[]) {
    if (null == listener || null == eventIds) return;
    for (BleEventImp id : eventIds) {
        map.put(id, listener);
    }
}

Interface:

public interface BleEvent {

	void updateView(BleEventImp eventId, String action, Object... obj);
}

However I'm getting an error stating: 'None of the following functions can be called with the arguments supplied:' and I'm unsure how I can go about resolving this.

Any suggestions are appreciated.

答案1

得分: 0

我看到BlueToothDriverActivity没有实现BleEvent接口。您需要实现它,然后您可以将this作为listener传递给addListener(BleEvent listener, BleEventImp eventIds[])

英文:

As I see BlueToothDriverActivity doesn't implement BleEvent interface. You need to implement it and then you can pass this to the addListener(BleEvent listener, BleEventImp eventIds[]) as listener.

huangapple
  • 本文由 发表于 2020年4月9日 14:07:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/61114925.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定