Mark: Thanks for your time and clarity.

On Friday, June 1, 2012 5:16:09 PM UTC-4, dev0708 wrote:
>
> I’ve observed two ways to handle a button press: #1 and #2 below. 
> - Can anyone explain the situations where I should use one or another? 
> - What is the proper terminology to describe the two techniques? 
> - Are there more ways to handle a button press? 
> Much thanks. 
>
>
> 1.        Set event handler in Main.xml 
> 1.1.        Main.xml: 
> 1.1.1.        <Button 
> 1.1.1.1.        android:id="@+id/buttonMine"… 
> 1.1.1.2.        android:onClick="runMyCode" 
> 1.2.        X.Java 
> 1.2.1.            public void changeToRed(View v) { 
> 1.2.2.                        tvResult.setText("Red"); 
>
>
> 2.        Set event handler in .java 
> 2.1.        Main.xml: 
> 2.1.1.         <Button 
> 2.1.1.1.        android:id="@+id/buttonMine"… 
> 2.2.        X.java: 
> 2.2.1.         Public class… implements OnClickListener… 
> 2.2.1.1.        Button btnMyButtonInCode;        // used for code ref to 
> object 
> 2.2.2.         Public onCreate 
> 2.2.2.1.                btnMyButtonInCode 
> =(Button)findViewById(R.id.buttonMine); 
> 2.2.2.2.                btnMyButtonInCode.setOnClickListener(this); 
> 2.2.3.         public void onClick(View v)… 
> 2.2.3.1.        (code to run when button pressed) 
>
>

-- 
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

Reply via email to