我遇到问题,使用RecyclerView,使用自定义适配器类进行改造,获取:
Change 2nd parameter of method 'VideoRecyclerAdapter' from 'Context' to 'Callback<ArrayList<VideoPojo>>'
Adapter.java:
public VideoRecyclerAdapter(ArrayList<VideoPojo> personList, Context context) {
mPersonList = personList;
mPref = context.getSharedPreferences("person", Context.MODE_PRIVATE);
mEditor = mPref.edit();
}
Activity.java:
videoAPI.getData(strJSON, new Callback<ArrayList<VideoPojo>>() {
@Override
public void success(ArrayList<VideoPojo> videoPojoList, Response response) {
try {
videoList = videoPojoList;
videoAdapter = new VideoRecyclerAdapter(videoList, this);
recyclerView.setAdapter(videoAdapter);
} catch (Exception e) {
}
}
});
API.java:
public interface VideoAPI {
@GET("/list/{name}")
void getData(@Path("name") String name, Callback<ArrayList<VideoPojo>> response);
}
答案 0 :(得分:3)
只需更改此行
即可videoAdapter = new VideoRecyclerAdapter(videoList, this);
到
videoAdapter = new VideoRecyclerAdapter(videoList, YourActivity.this);
内部界面 此被称为Callback<ArrayList<VideoPojo>>
。您需要Application
或Activity
上下文。