mitchtabian / Fragments

How to use Fragments in your Android Apps
18 stars 14 forks source link

Improve the call of MainActivity setViewPager #2

Open MaherSoua opened 7 years ago

MaherSoua commented 7 years ago

https://github.com/mitchtabian/Fragments/blob/4b0a74809f986563b694eb8ca89a595d1edb984e/Fragements/app/src/main/java/tabian/com/fragements/Fragment1.java#L49 May be we can use onAttach(Context context) in Fragment classes, like that we can get the main activity and use its public method like that I mean:

MainActivity mMainActivity; @Override public void onAttach(Context context){ super.onAttach(context); mMainActivity = (MainActivity) context; }

mitchtabian commented 7 years ago

Do whatever works for you.