I have a series of buttons in my mainactivity and when i click one of them i want to display their id but using view.getId() i get an integer and converting it to string i get a string of numbers,how can i get the id that i written on the xml?
public void giocaCarta(View view){
Toast.makeText(this,Integer.toString(view.getId()),Toast.LENGTH_LONG).show(); }
this is the code of the button:
<Button
android:id="@+id/btn_g2_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="giocaCarta"
android:text="Button" />
i want to read on the toast "btn_g2_1" and not a sequence of numbers,there is some method that can provide this?