non-static method getActivity()

后端 未结 4 837
情深已故
情深已故 2021-01-29 10:53

I made the method \"showResult\" static but i have problem with :

\"Toast.makeText(`getActivity()`.getApplication(), result2 + \"\\n\" + \"Total Amount:=\" + tot         


        
4条回答
  •  太阳男子
    2021-01-29 11:14

    Try using context instead of getActivity.getApplication()

    Declare context as:

    private static Context context = null;
    

    and then intialize it as:

    context=getActivity();
    

    and then Toast :

    Toast.makeText(context, result2 + "\n" + "Total Amount:=" + totalAmount2 + "€", Toast.LENGTH_LONG).show();
    

提交回复
热议问题