title: How can I reuse my code on each click of Floating Action Button in Kotlin?
body: <p>Here is my code which I used to print text_switch_on and text_switch_off on each click of floatingActionButton but after running my application it stopped working and black screen showed up.</p>
  <pre><code> while(true) {
          floatingActionButton.setOnClickListener {
              if (floatingActionButton.isEnabled()) {
                  button_switch_on_off.text = getString(R.string.text_switch_off)
              } else {
                  button_switch_on_off.text = getString(R.string.text_switch_on)
              }
          }
      }
  </code></pre>