I have tabs created with FragmentPagerAdapter
:
public class SectionsPagerAdapter extends FragmentPagerAdapter {
static final int PAGE_COUNT = 2;
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int index) {
switch (index) {
case 0:
return new SessionDetails();
case 1:
return new SessionScoreTable();
}
return null;
}
@Override
public int getCount() {
return PAGE_COUNT;
}}
I need to update one tab by clicking buttons on another one.
Parent FragmentActivity
has:
fragSessionDetails = (SessionDetails) mSectionsPagerAdapter.getItem(0);
and has function
:
public void setSessionCompleted(){
fragSessionDetails.processSessionCompleted();
}
which is called from another tab (SessionScoreTable
).
SessionDetails
tab has function:
public void processSessionCompleted(){
Log.d(TAG,"processSessionCompleted" );
bSave.setEnabled(false);
}
bSave is button.
In log I have NullPointerException
on row - bSave.setEnabled(false)
:
06-30 16:20:45.414: D/STS_SessionDetails(15876): processSessionCompleted 06-30 16:20:45.414: D/AndroidRuntime(15876): Shutting down VM 06-30 16:20:45.414: W/dalvikvm(15876): threadid=1: thread exiting with uncaught exception (group=0x41b62d88) 06-30 16:20:45.414: E/AndroidRuntime(15876): Exception 06-30 16:20:45.414: E/AndroidRuntime(15876): FATAL EXCEPTION: main 06-30 16:20:45.414: E/AndroidRuntime(15876): Process: com.vvv.vvvvvvvvvvvvv, PID: 15876 06-30 16:20:45.414: E/AndroidRuntime(15876): java.lang.NullPointerException 06-30 16:20:45.414: E/AndroidRuntime(15876): at com.vvv.vvvvvvvvvvvvv.SessionDetails.processSessionCompleted(SessionDetails.java:237) 06-30 16:20:45.414: E/AndroidRuntime(15876): at com.vvv.vvvvvvvvvvvvv.Session.setSessionCompleted(Session.java:151)
It looks like I lost something but have no idea what. Any help please.