Scalified / fab

Floating Action Button Library for Android
Apache License 2.0
849 stars 164 forks source link

Hiding and showing on Sections Pager #23

Closed Twissall closed 9 years ago

Twissall commented 9 years ago

Hi, I have an activity which has some section pagers of fragments. I want to dynamically hide and show the actionbutton depending on the fragment. Here is my scenario.

Main Activity inflates my layout with the actionbutton view.

onCreateView method for fragment_1. initActionButton()

onResume method Fragment_1 boolean shown = actionButton.isShown(); if (shown){ actionButton.setShowAnimation(ActionButton.Animations.ROLL_TO_DOWN); actionButton.dismiss(); }

private void initActionButton() { actionButton = (ActionButton) getActivity().findViewById(R.id.action_button); }

The first time it loads, the button is NOT visible. If I swipe to other fragments and return, it crashes: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.software.shell.fab.ActionButton.isShown()' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3224)

How can I resolve this? I have tried isEnabled() to the same effect.

vbaidak commented 9 years ago

Hi Twisssall,

So, the problem is in the Action Button initialization. In order to make it work I need to know what library you are using (if any). Please post the entire code of your activity, layout and fragments here or send me it to com.software.shell@gmail.com

I will try to help you

Twissall commented 9 years ago

Hi there.

Thank you for such a quick response. I debugged some more and realised that I was calling dismiss() instead of hide(). Once dismissed, I could not find the actionbutton view. Thanks again!

vbaidak commented 9 years ago

Hi,

Great

Best wishes, Shell Software Inc. On 8 Apr 2015 15:05, "Marsh" notifications@github.com wrote:

Hi there.

Thank you for such a quick response. I debugged some more and realised that I was calling dismiss() instead of hide(). Once dismissed, I could not find the actionbutton view. Thanks again!

— Reply to this email directly or view it on GitHub https://github.com/shell-software/fab/issues/23#issuecomment-90892702.

vbaidak commented 9 years ago

Issue solved