On Wed, Jan 20, 2010 at 11:35 AM, tim hansen <
[email protected]> wrote:
> final Builder builder = new AlertDialog.Builder(this);
>
> btnSave = (Button)findViewById(R.id.save_button);
>
> btnSave.setOnClickListener(new OnClickListener() {
> @Override
> public void onClick(View v) {
> builder.show();
> }
> });
>
I am no expert in Java, but I believe in this case you need the final
keyword to ensure that the "builder" variable that you're using in the
anonymous OnClickListener is still valid when it's onClick() function is
actually called.
If it were not final, the variable "builder" would be invalidated as soon as
you exited the onCreate() function. Later, when you actually press the save
button and the onClick() function gets called, builder would be null (or
complete garbage).
I'm sure someone will correct me if I'm mistaken.
-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking
--
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