[問題] 不透過xml檔來使用google map v2

看板AndroidDev作者 (songs)時間12年前 (2014/02/16 19:32), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
現在google map v2 不能像舊版一樣放入mapView 而要在 res-->layout-->main.xml 中 放入 <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" /> 而要加入這行 class="com.google.android.gms.maps.SupportMapFragment" 必須在xml檔中,來執行google map v2 我的問題是: 在我的程式中,不透過xml檔 來放入class是"com.google.android.gms.maps.SupportMapFragment"的view 請問有什麼辦法嗎? (像是addView(),addContentView()? 但目前找不到什麼方法放入這個google map的class) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.205.97.16

02/17 02:50, , 1F
如果把 map 做成單獨的 xml 檔
02/17 02:50, 1F

02/17 02:51, , 2F
然後用 inflator 產生 view 再 addview() 可以嗎?
02/17 02:51, 2F

02/18 19:03, , 3F
謝謝N大提供的方法 但似乎只能在一般的ui上執行
02/18 19:03, 3F

02/18 19:03, , 4F
而我忘了說我是要在Camera的畫面 所以執行了還是會錯誤..
02/18 19:03, 4F

02/23 08:52, , 5F
new SupportMapFragment
02/23 08:52, 5F
推n大 最後是用n大的方法完成 只是Activity後面 需要extend FragmentActivity ※ 編輯: AZHI 來自: 123.205.97.187 (03/19 20:25)
文章代碼(AID): #1J0A7cKW (AndroidDev)