If I'm inside a Fragment how can I call a parent's activity?
相关问题
- 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
Yes, Its right by calling getActivity and cast it with parent activity to access its methods or variables
((ParentActivityName)getActivity())
Try this one.
ParentActivityName
is parent class nameThe most proper way is to make your
Activity
implement anInterface
and use listeners. That way theFragment
isn't tied to any specificActivity
keeping it reusable. Into theFragment
:That way, you make the
Activity
listen to the fragment when it's attached to it.See also:
Simply call your parent activity using getActivity() method.