how many would you ask for an app for a big enterprise?
Asked
Active
Viewed 218 times
-1
-
Show `myFragmentPagerAdapter`, please – OneCricketeer Dec 07 '16 at 23:56
-
Also, try to create a [mcve]. Does this happen with all Fragments of the ViewPager, or can you take some out while you debug? – OneCricketeer Dec 07 '16 at 23:57
-
i have 3 Fragments in my ViewPager, only the infoFragment doesn't want to go to the activity , but i tried another acitvity and it works , so the fault must be in infoactivity .. where i use a tablayout – peukertje Dec 08 '16 at 00:03
1 Answers
2
have 3 Fragments in my ViewPager
Then why are you only getting two and the other is null?
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
new OnthaalFragment();
case 1:
new EventFragment();
default:
return null;
}
}
That number is determined by this, by the way
@Override
public int getCount() {
return this.mTabTitles.length;
}

OneCricketeer
- 179,855
- 19
- 132
- 245
-
no the fragmentpageradapter is for my tablayout on the infoactivity this has 2 tabs. – peukertje Dec 08 '16 at 00:14
-
but i have indeed 3 fragments on my viewpager , so my application starts with viewpager with 3 fragments and one fragment can't go to another activity thats called infoactivity. on that activity i have tablayout connected with this fragmentpageradapter. you understand? – peukertje Dec 08 '16 at 00:17
-
I'm saying that you should remove the `return null`, or return a fragment for position 2 – OneCricketeer Dec 08 '16 at 00:24
-
oke i set 'return' befor the other cases and indeed it haves me a new error. again a null pointer exception. can you help me again? – peukertje Dec 08 '16 at 00:57
-
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.vives.degavers, PID: 6115 java.lang.NullPointerException: Attempt to invoke interface method 'com.vives.degavers.adapter.EventAdapter com.vives.degavers.info.cedric.EventFragment$OnFragmentInteractionListener.getEventAdapter()' on a null object reference at com.vives.degavers.info.cedric.EventFragment.onCreateView(EventFragment.java:40) – peukertje Dec 08 '16 at 00:58
-
You should set a return before the other cases, you just needed to add another case, or remove the `default` case. Regarding the error. Yes it's different, but unrelated to your initial question. Your Activity is null at `EventFragment.onCreateView(EventFragment.java:40)`. That's all I can tell you. I can't see `EventFragment` in your question – OneCricketeer Dec 08 '16 at 01:03
-
You should post another question. That's an unrelated error. You never assigned `mListener` and so you cannot get the adapter from it. It's null. That's all I'll point out. – OneCricketeer Dec 08 '16 at 03:16