Fragment中获取Context

在Fragment的开发中,发现无法使用this字符来获取fragment的上下文。所以我们获取fragment的上下文时首先需要获取fragment对象。
View view = inflater.inflate(R.layout.fragment_home, container, false);
再调用view对象的getContext方法,来调用Context上下文。

view.getContext()

猜你喜欢

转载自blog.csdn.net/ct_ts/article/details/79808664