title: OnClick in Fragment - Only Firing Once
body: <p>My app has a tabbed screen with three fragments, two of which are the same but with different data.</p>
  <p><a href="https://i.stack.imgur.com/OmkIG.png" rel="nofollow noreferrer">Initial screen</a></p>
  <p><a href="https://i.stack.imgur.com/butQg.png" rel="nofollow noreferrer">With comments</a></p>
  <p>Clicking the comment down the bottom brings up the full list of comments and clicking the [x] closes the comments. This is done through animations and .setVisibility().</p>
  <p>The problem is I can only do this once as clicking the comment after closing it does nothing.</p>
  <p>Bringing up the comments is shown here - from debugging, the onClick fires if I don't mess with the visibilities so they must be causing a problem somewhere</p>
  <pre><code>comment_overview.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
              handleCommentOverviewClick(v);
         }
  });
  ...
  
  private void handleCommentOverviewClick(View v) {
          Log.d(&quot;OPEN&quot;, &quot;open&quot;);
          scrollView.fullScroll(ScrollView.FOCUS_UP);
          Animation bottomUp = AnimationUtils.loadAnimation(getContext(),
                  R.anim.slide_in_bottom);
          bottomUp.setAnimationListener(new Animation.AnimationListener() {
              @Override
              public void onAnimationStart(Animation animation) {
              }
  
              @Override
              public void onAnimationEnd(Animation animation) {
                  bottom_info_section.setVisibility(View.GONE);
                  // animation.cancel();
              }
  
              @Override
              public void onAnimationRepeat(Animation animation) {
              }
          });
  
          comment_section.startAnimation(bottomUp);
          comment_section.setVisibility(View.VISIBLE);
  }
  </code></pre>
  <p>Closing the comments is similar and shown below</p>
  <pre><code>private void handleCommentsClose(View v) {
          Log.d(&quot;CLOSE&quot;, &quot;cls&quot;);
          Animation topDown = AnimationUtils.loadAnimation(getContext(),
                  R.anim.slide_out_bottom);
          topDown.setAnimationListener(new Animation.AnimationListener() {
              @Override
              public void onAnimationStart(Animation animation) {}
  
              @Override
              public void onAnimationEnd(Animation animation) {
                  comment_section.setVisibility(View.GONE);
              }
  
              @Override
              public void onAnimationRepeat(Animation animation) {}
          });
          comment_section.startAnimation(topDown);
          bottom_info_section.setVisibility(View.VISIBLE);
      }
  </code></pre>
  <p>I've tried following advice of making the fragment implement OnClickListener and handling each clickable in a switch but I got the same behaviour - it would work once but not again unless I navigated away and came back.</p>
  <p>Would love any suggestions as I'm kinda stuck</p>