The message seems a bit different from what I'd expect, but I think
it's a matter of using final. Final for a primitive means you can't
change it (and if it were an object, it means you can't reassign to a
different object, but you can change the internal state of it). So,
probably define totalCost as a member variable of your class and drop
the final keyword.

On Apr 24, 5:24 pm, Kyle <[EMAIL PROTECTED]> wrote:
> Hi, I've been looking for a way of doing this, maybe it's just my lack
> of thought, or maybe I'm just too noob at Java, but I'm trying to get
> EditText text (can do this), send to a string (can also do this)
> convert to int, add to a global int, and then write the global int to
> a TextView. Here is my code:
>
> final int totalCost=0;
> btnAddCost.setOnClickListener(new Button.OnClickListener() {
>             public void onClick(View v) {
>                 final String value = btnAddCost.getText().toString();
>                 totalCost = Integer.parseInt(value);
>                 txtTotalCost.setText("$"+totalCost);
>             }
>         });
>
> Eclipse returns an error saying:
> The final local variable totalCost cannot be assigned, since it is
> defined in an enclosing type
>
> Any ideas? Basically what it is, is a price updater, adds the amount
> of money you typed in, to the TextView (txtTotalCost)
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to