My View
<Button android:id="@+id/button1" android:text="Text 1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></Button>
<Button android:id="@+id/button2" android:text="Text 2"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></Button>
<Button android:id="@+id/button3" android:text="Text 3"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></Button>
<Button android:id="@+id/button4" android:text="Text 4"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></Button>
I have an undefined amount of buttons and need get you text in a touch event.
How i do it?
Tnks a lot.
EDIT:
Thanks for all, this is result of the your Answers => https://play.google.com/store/apps/details?id=br.com.redrails.torpedos
My App 😀
If you name all of your buttons “button1, button2, button3…” you can do this:
Where
buttonCountis the amount of buttons you have. This method would be placed inonCreate().Then for your onClick:
Your Activity will need to implement
OnClickListener