Android (安卓) getContext 和 getActivity的区别

Posted ZhangJiQun.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android (安卓) getContext 和 getActivity的区别相关的知识,希望对你有一定的参考价值。

目录

Android (安卓) getContext 和 getActivity的区别

在Fragment中使用findViewById方法

int类型的图片转换成drawable和Bitmap


android (安卓) getContext 和 getActivity的区别

getActivity()获得Fragment依附的Activity对象,返回活动此片段是当前关联 ,

getView()返回该 片段的根视图布局(由onCreateView(LayoutInflater, ViewGroup,Bundle)返回的布局)

  • MainActivity.this:表示MainActivity对象,一般用在

以上是关于Android (安卓) getContext 和 getActivity的区别的主要内容,如果未能解决你的问题,请参考以下文章

Android:getContext().getSystemService()

Android:Fragment 新的 getContext() 方法是哪个上下文?

8.16安卓开发 注意事项

如何实现appium移动端的新特性:getContexts for android混合自动化

getContext() 不存在

安卓获取屏幕的宽度与高度