看板 AndroidDev 關於我們 聯絡資訊
因為想在mapview上新增很多balloon對話框 然後自己也畫了一個balloon的layout 但是使用for迴圈新增後 顯然是不行的 因為system err會叫我要removeView() 所以這樣明顯只能用一個 有甚麼好方法呢?? for(int i=0;i<c.getCount();i++){ id[i] = String.valueOf(c.getInt(0)); //以下是撈資料 name[i] = c.getString(5); latitude[i] = c.getString(6); longitude[i] = c.getString(7);//以上是撈資料 double lat =Double.parseDouble(latitude[i])*1E6; double lon =Double.parseDouble(longitude[i])*1E6; GeoPoint gp = new GeoPoint((int)lat,(int)lon); bubblelayout noteBaloon = (bubblelayout) layoutInflater.inflate( .layout.overlay_bubble, null);//修改處 ((TextView) noteBaloon.findViewById(R.id.note_label)).setText(name[i]); mMapView.addView(noteBaloon, new MapView.LayoutParams(280, 100, gp, MapView.LayoutParams.BOTTOM_CENTER)); mMapView.setEnabled(true); c.moveToNext(); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.48.94
tericky:可以疊很多層啊 看你是要一層一個點 還是要一層多個點都可 08/13 07:07
tericky:不過,如果你是很多點要顯示,一層多點會比較理想 08/13 07:08
tericky:你的問題出在...一個MapViewActivity裡面,只能允許有一個 08/13 07:09
tericky:MapView,所以你不應該是用MapView.addView(MapView) 08/13 07:10
tericky:而是要用 MapView.getOverlays().add(Overlay) 08/13 07:12
oralB:不好意思,那要怎麼在overlay放上layout呢?? 08/13 12:14
tericky:overlay裡面要放layout? 08/13 14:03
※ 編輯: oralB 來自: 61.224.48.94 (08/13 14:36)
oralB:我發現我現在可以新增很多layout了,因為notebaloon是我寫的 08/13 14:37
oralB:extands linearlayout,把他宣告在for迴圈裡就好,變區域 08/13 14:38
※ 編輯: oralB 來自: 61.224.48.94 (08/13 14:40)
oralB:像我上面已經加的那一行,但是問題來了,我的layout有button 08/13 14:41
oralB:這樣寫反而不能控制那個BUTTON了= = 08/13 14:41