title: How to toggle ImageView buttons
body: <p>I am currently having three Imageview Buttons, which calls three different functions in my android app. Instead of 3 buttons, I want to use a single button, which should call each function on each tap (Like a toggle button).  Please find my current XML structure of the three independent buttons (ImageView)</p>
  
  <pre><code>&lt;ImageView
          android:id="@+id/img_align_left"
          android:layout_width="@dimen/icon_width"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:contentDescription="TODO"
          android:padding="10dp"
          app:srcCompat="@drawable/ic_format_align_left" /&gt;
  
      &lt;ImageView
          android:id="@+id/img_align_center"
          android:layout_width="@dimen/icon_width"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:padding="10dp"
          app:srcCompat="@drawable/ic_format_align_center" /&gt;
  
      &lt;ImageView
          android:id="@+id/img_align_right"
          android:layout_width="@dimen/icon_width"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:padding="10dp"
          app:srcCompat="@drawable/ic_format_align_right" /&gt;
  </code></pre>
  
  <p>And here is the fucntion calling script, which is used in the main activity.</p>
  
  <pre><code> img_align_left.setOnClickListener { alingnText(View.TEXT_ALIGNMENT_TEXT_START) }
      img_align_center.setOnClickListener { alingnText(View.TEXT_ALIGNMENT_CENTER) }
      img_align_right.setOnClickListener { alingnText(View.TEXT_ALIGNMENT_TEXT_END) }
  </code></pre>
  
  <p>Let me know if the query gives you enough information. 
  Thank you!</p>
  
  <p>-------------------------UPDATE-------------------------------------</p>
  
  <p>Based on @Kam code, I was able to solve the issue ( I use Kotlin). Here is the code.</p>
  
  <pre><code>    var count=0
          img_align_left.setOnClickListener {
  
              when (count) {
                  0 -&gt; {
                      alingnText(View.TEXT_ALIGNMENT_TEXT_START)
                  }
  
  
                  1 -&gt; {
              alingnText(View.TEXT_ALIGNMENT_CENTER)
                  }
  
                  2 -&gt;
              {alingnText(View.TEXT_ALIGNMENT_TEXT_END)}
  
              }
  
  if(count&gt;1)
          count=0
          else
          count++}
  </code></pre>
  
  <p>Thank you :)</p>