英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论