Hi Rockline
Use
android:onClick="selfDestruct"
in your xml where you have define Buttons,
So for each button you can saprate function in java class which will be
invoked when you click on it
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1"
android:onClick="button1Click" />
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2"
android:onClick="button2Click" />
Where button1Click and button2Click are your java functions
You can Read more about this here
http://developer.android.com/reference/android/widget/Button.html
On Tue, Jul 5, 2011 at 10:02 AM, Rockline <[email protected]> wrote:
> Hi all,
>
> I'm having a beginner issue. Sorry if my issue looks pathetic.
>
> I've got a custom button class so that I can declare lots of custom
> button objects in my Activity. The buttons are declared via an XML
> file. Each button is identified by a different text inside it
> ( setText("blabla") ).
>
> I'd like to update the text of a label Alpha in my Activity depending
> on which button has been pressed.
> How do I do (considering I've got hundreds of buttons) to identify
> which button was pressed?
>
> ex:
> public class MyActivity extends Activity implements OnClickListener {
> }
>
> public class MyCustButton extends Button {
> }
>
>
> Thanks.
> Best regards.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en