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資源作爲參數傳入進去