1、 getActivity():获得Fragment依附的Activity对象
/**
* Return the {@link FragmentActivity} this fragment is currently associated with.
* May return {@code null} if the fragment is associated with a {@link Context}
* instead.
*
* @see #requireActivity()
*/
@Nullable
final public FragmentActivity getActivity() {
return mHost == null ? null : (FragmentActivity) mHost.getActivity();
}
2、 getContext():View类中提供的方法,在继承了View的类中才可以调用,返回的是当前View运行在哪个Activity中。
3、setText():给TextView设置文字的时候,会调用该方法,通常会把String或者String资源作为参数传入进去