0

I have an app with 3 tabs. The fragments for each tab are created with a SectionsViewPager. I've created a Reloadable interface with 1 method void reload(Context ctx);. On the actionBar I've added a reload button. When the button is pressed I'm checking if the fragment implements Reloadable and if it does, I call reload(this);.

So far so good...

In the app I've previously included a pull-to-refresh functionality, but because this does not feel very "Androidy" I want to replace it with the above described functionality (reload button in actionBar, when pressed, refresh fragment). The pull-to-refresh function worked fine by the way. I've remapped the reload function to the new one from the Reloadable interface.

Now I'm testing my reload button and the app crashes.

The app crashes because apparently one of my TextViews isn't bound to my ivar when using the reload button. It is bound when I use pull-to-refresh though. The following is the relevant code:

mTextView.setVisibility(isEmpty ? View.VISIBLE : View.INVISIBLE);

mTextView is null when called through the reload button on actionBar. It's not null when using the pullToRefresh functionality that's part of the fragment. What is going wrong here?

Wolfgang Schreurs
  • 11,779
  • 7
  • 51
  • 92
  • Is your reload button part of the activity menu or part of the fragment menu? I'd recommend putting it as part of the fragment menu and simply calling your reload function from `onOptionsItemSelected`. – ebarrenechea Feb 25 '13 at 18:35
  • It's currently part of the activity menu. Gonna try using the fragment menu. – Wolfgang Schreurs Feb 25 '13 at 20:01

0 Answers0