title: How to get ID of imagebutton when it is clicked
body: <pre><code>public void onClick(View v) {
  
      int id = v.getId();
      switch(id) {
          case R.id.a :
          String textans = ans.getText().toString();
          ans.setText(textans +id);
      }
  }
  </code></pre>
  
  <p>I am creating an android application in which i have 5 <code>ImageButton</code>s and a <code>TextView</code>.</p>
  
  <p><code>ImageButton</code>s are having alphabet images i.e A, B, C, D, E and their ID's in XML are a, b, c, d, e as follows</p>
  
  <pre><code>&lt;ImageButton
          android:id="@+id/a"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_marginBottom="170dp"
          android:layout_marginLeft="18dp"
          android:src="@drawable/a" /&gt;
  
      &lt;ImageButton
          android:id="@+id/b"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/imageButton5"
          android:layout_toRightOf="@+id/imageButton5"
          android:src="@drawable/b" /&gt;
  
      &lt;ImageButton
          android:id="@+id/c"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/imageButton2"
          android:layout_toRightOf="@+id/imageButton2"
          android:src="@drawable/c" /&gt;
  
      &lt;ImageButton
          android:id="@+id/d"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/imageButton3"
          android:layout_toRightOf="@+id/imageButton3"
          android:src="@drawable/d" /&gt;
  
      &lt;ImageButton
          android:id="@+id/e"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/a"
          android:layout_toRightOf="@+id/a"
          android:src="@drawable/e" /&gt;
  </code></pre>
  
  <p>What I want is when I click an <code>ImageButton</code> the respective letter must be set in <code>TextView</code>. For this purpose I have used a <code>switch</code> in <code>onClick</code> method and tended to get the ID of the button and set it in <code>TextView</code> but id is something in <code>int</code>.</p>
  
  <p>My question is this "How can I get the name of the ID of button clicked". For example when Iclick button having image A, the id of <code>ImageButton</code> is "<strong>a</strong>", so it must be stored in a variable and then it is set to <code>TextView</code>.</p>
  
  <p>Hopefully my question is much clear.</p>