I am trying to do a tab layout same in Play Store. I got to display the tab layout using a fragments and viewpager from androidhive. However, I can't implement google maps v2 on it. I searched the internet for hours already, but I can't find a tutorial on how to do it. Can some one please show me how?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
For the issue of getting a
NullPointerException
when we change the Tabs in aFragmentTabHost
you just need to add this code to your class which has theTabHost
. I mean the class where you initialize the tabs. This is the code :You can use this line if you want to use
GoogleMap
in a fragment:in fragment_layout
here what i did in detail:
From here you can get google map api key
alternative and simple way
first log in to your google account and visit google libraries and select Google Maps Android API
dependency found in android studio default map activity :
put your key into android mainifest file under application like below
in AndroidMainifest.xml make these changes:
Fragment code :
in you fragment xml :
Latest stuff with
getMapAsync
instead of the deprecated one.1. check manifest for
You can get the API Key for your app by registering your app at
Google Cloud Console
. Register your app as Native Android App2. in your fragment layout .xml add FrameLayout(not fragment):
or whatever height you want
3. In onCreateView in your fragment
I've a workaround for
NullPointerException
when remove fragment in onDestoryView
, Just put your code inonStop()
notonDestoryView
. It works fine!