【发布时间】:2012-06-06 19:52:09
【问题描述】:
我有一个名为TouchImageView extends ImageView 的类,我检测用户点击它的位置。如果这是一个兴趣点,我想在Detailed_Image_Activity 上调用一个方法来更新WebView。我怎样才能做到这一点?
我发现了一些关于使用观察者和可观察对象的想法,但我不知道该怎么做。我找到了这个解决方案Equivalent of iOS NSNotificationCenter in Android?,但我无法让它发挥作用
这是我在 TouchImageView 类中的代码...
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if(isPointOfInterest) {
//The code below is used to update the WebView
//The task called below exists in the Detailed_Image_Activity
DownloadHighlightBackground HighlightDownloaderTask = new DownloadHighlightBackground();
HighlightDownloaderTask.execute(new String[] { arg1.toString() });
}
}
【问题讨论】:
标签: java android observer-pattern