0

I am getting the following error on Shopping.this:

non-static variable this cannot be referenced from a static context.

How should I change my code besides changing getShipping() to non-static?

public class Shopping extends Activity {
   public static final String total_weights = "weight";

    public static double getShipping(double total_weight) {
        String weight = Double.toString(total_weight);
        System.out.println(weight);
        Intent intent = new Intent(Shopping.this,shopping1.class);
        intent.putExtra(total_weights, weight);
        Shopping.this.startActivity(intent);
     }
}
CubeJockey
  • 2,209
  • 8
  • 24
  • 31
Cheong Charlene
  • 275
  • 1
  • 2
  • 12

0 Answers0