title: how can I make a button click function be clicked multiple times?
body: <p>I'm creating an application with topics and a paragraph under the topic.</p>
  
  <p>When the user clicks on the topic it sets the paragraph visible and on re-click it sets it to gone. It can only be clicked once, how can I make it happen 10 times? without writing the function 10 times</p>
  
  <p>I have tried adding recreate(); under b1.setTextColor, it only recreates the function. I also have the same function for topic b2,b3,b4 etc. When all the topics are clicked and visibility changed to VISIBLE, the user presses on b1 to close it, it sets all the other topics visibility to GONE.</p>
  
  <pre><code>        final LinearLayout lb1 = findViewById(R.id.b_title1a);
          final TextView b1 = findViewById(R.id.b_title1);
          b1.setTextColor(getResources().getColor(R.color.colorPrimary));
          b1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  lb1.setVisibility(View.VISIBLE);
                  b1.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
                  b1.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          lb1.setVisibility(View.GONE);
                          b1.setTextColor(getResources().getColor(R.color.colorPrimary));
  
                      }
                  });
              }
          });
  </code></pre>
  
  <p>Is there a way to repeat the function or how to loop it?
  By-means the user stays on activity and be-able to open and close a topic as many times as the user can.</p>
  
  <pre><code>     b1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  lb1.setVisibility(View.VISIBLE);
                  b1.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
                  b1.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          lb1.setVisibility(View.GONE);
                          b1.setTextColor(getResources().getColor(R.color.colorPrimary));
                          recreate();
  
                      }
                  });
              }
          });
  </code></pre>
  
  <p>This works, but the code is not clean it gives problems</p>