0
I have several buttons in a view that call the addNumero method in Onclick, something like this:
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:onClick="addNumero"
android:text="8" />
And since there are many buttons, it is impossible to use the setOnClickListener
in each.
I have a class that inherits from Fragment: public class Exemplo extends Fragment
and est class inflates the view that contains the buttons and in that class is also the method addNumero
but it’s not working, when I click it doesn’t call the addNumero.
The use of
android:onClick
only works when the view is used in an Activity.– ramaral
So, but my view is used in a fragment, that’s the problem
– Brenddon Anjos
Like the
android:onClick
does not work in a Fragment must usesetOnClickListener()
.– ramaral