Thanks alot for all your help. My program now works.

Since Im a Computer Science Major they dont usualy teach GUI
programming so setting up a listener is somewhat forgen to me.

On Jan 18, 10:17 am, Mark Murphy <mmur...@commonsware.com> wrote:
> Eddie O'Hagan wrote:
> > I think I found what u were talking about.
>
> > myCalcButton.setOnClickListener(new Button.OnClickListener()
> >            {
> >                    public void onClick(View v)
> >                    {
> >                            double billNum = 
> > Double.parseDouble(myBillAmt.getText
> > ().toString());
> >                    double preNum = Double.parseDouble
> > (myPrecentage.getText().toString());
>
> >                    myAns.setText(""+calcTip(billNum,preNum));
> >                    }
> >            }
> >         );
>
> > I dont relly understand what is going on here though. Could you please
> > explain this to me?
>
> This is pretty typical for widget-based GUI development, at least on
> Java. You are passing the Button an OnClickListener object. The Button
> will call onClick() on that OnClickListener when the Button is clicked.
> In there, you are doing your tip calculation and updating the TextView
> with the results.
>
> If your concerns lie with the "new Button.OnClickListener()" syntax, you
> will want to read up on "anonymous inner classes".
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Published!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to