作者m4u06 (meleo)
看板AndroidDev
标题[问题] 如何删除google地图上,画的线条
时间Sun Nov 30 18:37:04 2014
第一次发文,如有那里说不清楚,请见谅了
最近开始学android,算是出於兴趣,java程度算会基础而已
我想要让我的功能表上
打勾前显示A线(并删掉B线),打勾後显示B地图(并删掉B线)
上网爬了一下文好像跟remove()有关,我试过把remove放各位置
目前的当点选两次後,两条线都会出现,不会把旧的删掉
这是我的程式码,如果知道我的问题请跟我说了,谢谢:)
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.sss;
boolean sss = false;
sss = !sss;
item.setChecked(!sss);
PolylineOptions one = new PolylineOptions();
one.add(new LatLng(25.034026, 121.565435));
one.add(new LatLng(25.032981, 121.565419));
one.add(new LatLng(25.033010, 121.563590));
one.color(Color.RED);
Polyline polylinee = map.addPolyline(one);
PolylineOptions two = new PolylineOptions();
two.add(new LatLng(25.034296, 121.563585));
two.add(new LatLng(25.034981, 121.563601));
two.add(new LatLng(25.034966, 121.564985));
two.color(Color.BLUE);
Polyline polylineeeee = map.addPolyline(two);
polylineeeee.setWidth(10);
if(sss){
polylineeeee.remove(); }
else{
polylinee.remove(); }
break;
}
return super.onOptionsItemSelected(item);
}
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.237.250.107
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/AndroidDev/M.1417343827.A.AAF.html
1F:→ changyuheng: 自己写无妨,但要交流的话应该注意一下 coding style 12/01 00:38