在片段中没有调用AfterViews方法?

时间:2016-09-12 22:25:48

标签: android android-fragments android-viewpager android-annotations

我在class Program { static void Main(string[] args) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); List<double> Primes = new List<double>(); const double Start = 0; const double End = 100000; double counter = 0; int lastInt = 0; for (int i = 0; i < End; i++) Primes.Add(i); for (int i =0;i< Primes.Count;i++) { lastInt = (int)Primes[i] - RoundOff((int)Primes[i]); Primes[i] = (int)CheckForPrime(Primes[i], Math.Round(Primes[i] / 2)); if (Primes[i] != 0) { Console.Write(", {0}", Primes[i]); counter++; } } stopwatch.Stop(); Console.WriteLine("\n\nNumber of prime-numbers between {0} and {1} is: {2}, time it took to calc this: {3} (millisecounds).\n\n" + " The End\n", Start, End, counter, stopwatch.ElapsedMilliseconds); } public static double CheckForPrime(double Prim, double Devider) { if (Prim / Devider == Math.Round(Prim / Devider)) return 0; else if (Devider > 2) return CheckForPrime(Prim, Devider - 1); else return Prim; } public static int RoundOff(int i) { return ((int)Math.Floor(i / 10.0)) * 10; } } 类中使用Android annotation但未调用Fragment带注释的方法。这是代码:

@AfterViews

我在这里做错了什么?我检查了我的调试点,它没有进入@EFragment(R.layout.fragment_onboarding_base) public class AddEntityFragment extends Fragment { @ViewById ViewPager onBoardingViewPager; public static AddEntityFragment newInstance() { AddEntityFragment addEntityFragment = new AddEntityFragment(); return addEntityFragment; } @AfterViews void afterViewCreated(){ onBoardingViewPager.setAdapter(new CustomOnBoardingPagerAdapter(getChildFragmentManager(), getContext())); } } 方法。任何帮助都会很明显。

1 个答案:

答案 0 :(得分:1)

问题是您没有使用生成的类。你应该这样做:

AddEntityFragment fragment = AddEntityFragment_.builder().build();
// add the fragment in a transaction