-1
class EndpointsAsyncTask extends AsyncTask<Integer, Void, MyBean> {
private static MyApi myApiService = null;
public EndpointsAsyncTask(){
MyApi.Builder builder=new MyApi.Builder(AndroidHttp.newCompatibleTransport(),new AndroidJsonFactory(),null);
myApiService=builder.build();
}
@Override
protected MyBean doInBackground(Integer... params)
{
int no1=params[0];
try {
return myApiService.addition(no1).execute();
// return myApiService.addition(name).execute().getNo1();
} catch (IOException e){
Log.e("EndpointsAsyncTask",e.getMessage());
return null;
}
}
@Override
protected void onPostExecute(MyBean myBean) {
Toast.makeText(this,myBean.getNo1(),Toast.LENGTH_LONG).show();
}
我創建了一個名爲MyBean的類,它有一個方法setter和setNo1和getNo1的getter。 我想顯示在吐司getNo1但我越來越錯誤無法解析方法maketext(com.example.sampleapp.EndpointAsynctask,java.lang.Integer,int)無法解析端點
敬酒要求的上下文。你的asynctask不是一個上下文。 – njzk2