I am jumping into android dev.  I am a web developer(.net) .  I
watched a pretty good video on android dev, but have a question I
cannot figure out.  Below is my code:


package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;



public class HelloAndroid extends Activity implements OnClickListener
{
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {

                Button Btn1, Btn2, Btn3;
                TextView Txt1;
                int score =15;
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                //Start the Events

                Btn1 = (Button)findViewById(R.id.Btn_1);
                Btn2 = (Button)findViewById(R.id.Btn_2);
                Btn3 = (Button)findViewById(R.id.Btn_3);
                Txt1 = (TextView)findViewById(R.id.Txt1);
                //Initialize the text box

                Txt1.setText(String.valueOf(score));

                //Button Listeners

                Btn1.setOnClickListener(this);
                Btn2.setOnClickListener(this);
                Btn3.setOnClickListener(this);



     }

        @Override
        public void onClick(View src) {
                // TODO Auto-generated method stub

                switch(src.getId())
           {
           case R.id.Btn_1:

                      score++
                       break;
           case  R.id.Btn_2:
               break;
           case  R.id.Btn_3:
               break;
             }
           }
        }

My question is this.  The variable score seems to be out of scope in
the onclick function.  In fact, it will not compile and gives me an
error, but the instructor ran it no problem...and it seemed to me that
we had the same code.

Any Thoughts?

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