I have a slider that can be pulled up and then it shows a map.
(我有一个可以拉起的滑块,然后显示地图。)
I can move the slider up and down to hide or show the map. (我可以上下移动滑块以隐藏或显示地图。)
When the map is on front, I can handle touch events on that map. (当地图在最前面时,我可以处理该地图上的触摸事件。)
Everytime I touch, a AsyncTask
is fired up, it downloads some data and makes a Toast
that displays the data. (每次触摸时,都会触发AsyncTask
,它会下载一些数据并制作一个Toast
显示数据。)
Although I start the task on touch event no toast is displayed, not till I close the slider. (尽管我在触摸事件上启动任务,但没有显示吐司,直到关闭滑盖。)
When the slider is closed and the map is not displayed anymore the Toast
appears. (当关闭滑块并且不再显示地图时,将显示Toast
。)
Any ideas?
(有任何想法吗?)
Well start the task
(好好开始任务)
EDIT:
(编辑:)
public boolean onTouchEvent(MotionEvent event, MapView mapView){
if (event.getAction() == 1) {
new TestTask(this).execute();
return true;
}else{
return false;
}
}
and in onPostExecute
make a toast
(并在onPostExecute
敬酒)
Toast.makeText(app.getBaseContext(),(String)data.result,
Toast.LENGTH_SHORT).show();
In new TestTask(this)
, this is a reference to MapOverlay
and not to MapActivity
, so this was the problem.
(在新的TestTask(this)
,这是对MapOverlay
的引用,而不是对MapActivity
的引用,因此这就是问题所在。)
ask by Upvote translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…