如何从静态上下文传递数据?

时间:2016-04-18 13:55:46

标签: java android

我在Shopping.this上收到以下错误:

  

非静态变量,不能从静态上下文引用。

除了将getShipping()更改为非静态外,我应该如何更改代码?

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);
     }
}

0 个答案:

没有答案