accesing Button from one class to another
<p>I have declared a button in A.Class and have set disabled.</p>

<pre><code>public static Button s1=(Button)findViewById(R.id.sn1);
s1.setEnabled(false);
</code></pre>

<p>Now i want to enable this button in another class(B.class)
I tried enabling this button by giving 
 Button s2=A.s1;
But its throwing an error saying "Cannot make a static reference to the non-static method findViewById(int) from the type Activity"</p>

<p>Pls help me in correcting the error </p>

<pre><code>    `First Class:

    public class Mapper extends Activity implements OnClickListener 
    {
public static int sng=0,c=0;
public static double lat;
public static double lon;
public String placenametemp;
public Bundle savedInstanceState;
public static int chk= MapMe.check;
 LocationManager locman1= MapMe.locman;
 MyOwnLocationOverlay mylocover=MapMe.myLocationOverlay;
public MediaPlayer msong=MapMe.mp;
***public Button s1=(Button)findViewById(R.id.sn1);***



@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

 // Add Click listeners for all buttons
    View firstButton = findViewById(R.id.geocode_button);
    firstButton.setOnClickListener(this);
    View secondButton = findViewById(R.id.latlong_button);
    secondButton.setOnClickListener(this);
    View thirdButton = findViewById(R.id.presentLocation_button);
    thirdButton.setOnClickListener(this);
    View selectsong=findViewById(R.id.song_select);
    selectsong.setOnClickListener(this);
    s1.setOnClickListener(this);
    s1.setEnabled(false);


    }
 }


Second Class :
    public class MapMe extends MapActivity implements LocationListener 
  {

Button s1=(Button)findViewById(R.id.sn1);
public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);  // Suppress title bar to give more space
    setContentView(R.layout.mapme); 

    updateGPSprefs();

    // Set up location manager for determining present location of phone
    locman = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 

    // Listener for GPS Status...   
    final GpsStatus.Listener onGpsStatusChange = new GpsStatus.Listener(){
        public void onGpsStatusChanged(int event){
            switch(event){
                case GpsStatus.GPS_EVENT_STARTED:
                    // Started...
                break;
                case GpsStatus.GPS_EVENT_FIRST_FIX:
                    // First Fix...
                    Toast.makeText(MapMe.this, "GPS has First fix",       
                     Toast.LENGTH_LONG).show();
                break;
                case GpsStatus.GPS_EVENT_STOPPED:
                    // Stopped...
                break;
                case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                    // Satellite update
                break;
            }
            GpsStatus status = locman.getGpsStatus(null);


            Iterable&lt;GpsSatellite&gt; satlist = status.getSatellites();
        }
    };
   public  void fu(double a,double b,double c,double d)
{

    if((val==0)&amp;&amp;(val1==0))
            {
        mp.reset();
        try {

            check=1;
            System.out.println("matched");
            mp.setDataSource(link1);
            mp.prepare();
            mp.start();
            Toast.makeText(MapMe.this, "playing", Toast.LENGTH_LONG).show();
            System.out.println("Song button1");
            ***s1.setEnabled(true);***
           System.out.println("Song button");
        }

        catch(Exception e)
        {

        }
        }
</code></pre>

<p>`</p>
