将自定义列表值适配器传递给 activity
Pass the custom list value adapter to activity
我正在使用 Retrofit 概念,我需要将列表值传递给 activity。在这里,我附上了从后端获得响应的代码。
private void callCheckTopCourseDetails(String getId) {
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
Call<Example> call2 = apiInterface.doGetWishlist(getId);
call2.enqueue(new Callback<Example>() {
@Override
public void onResponse(Call<Example> call, Response<Example> response) {
if (response.code() == RESPONSECODE_200 || response.code() == RESPONSECODE_201) {
List<RatingsDetail> getRatingDetails = response.body().getAndroid().getRatingsDetails();
List<CourseDetail> getCourseDetail = response.body().getAndroid().getCoursedetails();
}
}
@Override
public void onFailure(Call<Example> call, Throwable t) {
Log.i("ttttttttt", "" + t);
call.cancel();
}
});
}
我是这样通过的,对我有用
private void callCheckTopCourseDetails(String getId) {
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
Call<Example> call2 = apiInterface.doGetWishlist(getId);
call2.enqueue(new Callback<Example>() {
@Override
public void onResponse(Call<Example> call, Response<Example> response) {
if (response.code() == RESPONSECODE_200 || response.code() == RESPONSECODE_201) {
List<RatingsDetail> getRatingDetails = response.body().getAndroid().getRatingsDetails();
List<CourseDetail> getCourseDetail = response.body().getAndroid().getCoursedetails();
String getratingcouts = response.body().getAndroid().getRatingsCounts().getMembercount();
String gettotcount=response.body().getAndroid().getRatingsCounts().getTotalrating();
int getcalc=response.body().getAndroid().getRatingsCounts().getCalculation();
Bundle bundle = new Bundle();
bundle.putSerializable("RatingDetails", (Serializable) getRatingDetails);
bundle.putSerializable("CourseDetails", (Serializable) getCourseDetail);
bundle.putString("getembercount",getratingcouts);
bundle.putString("gettotcount",gettotcount);
bundle.putInt("gettotcount",getcalc);
Intent intent = new Intent(context, CourseDetailActivity.class);
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
}
}
@Override
public void onFailure(Call<Example> call, Throwable t) {
Log.i("ttttttttt", "" + t);
call.cancel();
}
});
}
我正在使用 Retrofit 概念,我需要将列表值传递给 activity。在这里,我附上了从后端获得响应的代码。
private void callCheckTopCourseDetails(String getId) {
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
Call<Example> call2 = apiInterface.doGetWishlist(getId);
call2.enqueue(new Callback<Example>() {
@Override
public void onResponse(Call<Example> call, Response<Example> response) {
if (response.code() == RESPONSECODE_200 || response.code() == RESPONSECODE_201) {
List<RatingsDetail> getRatingDetails = response.body().getAndroid().getRatingsDetails();
List<CourseDetail> getCourseDetail = response.body().getAndroid().getCoursedetails();
}
}
@Override
public void onFailure(Call<Example> call, Throwable t) {
Log.i("ttttttttt", "" + t);
call.cancel();
}
});
}
我是这样通过的,对我有用
private void callCheckTopCourseDetails(String getId) {
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
Call<Example> call2 = apiInterface.doGetWishlist(getId);
call2.enqueue(new Callback<Example>() {
@Override
public void onResponse(Call<Example> call, Response<Example> response) {
if (response.code() == RESPONSECODE_200 || response.code() == RESPONSECODE_201) {
List<RatingsDetail> getRatingDetails = response.body().getAndroid().getRatingsDetails();
List<CourseDetail> getCourseDetail = response.body().getAndroid().getCoursedetails();
String getratingcouts = response.body().getAndroid().getRatingsCounts().getMembercount();
String gettotcount=response.body().getAndroid().getRatingsCounts().getTotalrating();
int getcalc=response.body().getAndroid().getRatingsCounts().getCalculation();
Bundle bundle = new Bundle();
bundle.putSerializable("RatingDetails", (Serializable) getRatingDetails);
bundle.putSerializable("CourseDetails", (Serializable) getCourseDetail);
bundle.putString("getembercount",getratingcouts);
bundle.putString("gettotcount",gettotcount);
bundle.putInt("gettotcount",getcalc);
Intent intent = new Intent(context, CourseDetailActivity.class);
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
}
}
@Override
public void onFailure(Call<Example> call, Throwable t) {
Log.i("ttttttttt", "" + t);
call.cancel();
}
});
}