无法解析端点

时间:2015-07-19 16:50:28

标签: android

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和getter,带有setNo1和getNo1。 我想在toast getNo1中显示但是我收到错误无法解析方法maketext(com.example.sampleapp.EndpointAsynctask,java.lang.Integer,int)

1 个答案:

答案 0 :(得分:0)

您的活动名称是什么? 将您的活动名称视为MyActivity

更改

Toast.makeText(this,myBean.getNo1(),Toast.LENGTH_LONG).show();

Toast.makeText(MyActivity.this,myBean.getNo1(),Toast.LENGTH_LONG).show();