我得到了一个按钮的以下 onClick 命令。但是当我调用它时,什么都没有出现代码:
public void onClick(View v) {
Log.d("debug", "before loadGutschein");
loadGutschein();
ViewFlipperVino.setDisplayedChild(3);
layout_number = 3;
Log.d("debug", "after loadGutschein");
bottomAudioLogosLayout.postDelayed(new Runnable() {
DisplayMetrics metrics = getActivity().getResources().getDisplayMetrics();
int width = metrics.widthPixels;
@Override
public void run() {
Log.d("debug", "couponsout=" + coupons);
if (coupons != null) {
int coupSize = coupons.size();
final int itemWidth = (width / coupSize) - 5;
for (int i = 0; i < coupSize; i++) {
Coupon coupon = coupons.get(i);
if (coupon.getImage() != null) {
final CheckBox cb = new CheckBox(getActivity());
final ImageView iv = new ImageView(getActivity());
iv.setScaleType(ScaleType.CENTER_INSIDE);
LayoutParams linearLayoutParams = new LayoutParams();
iv.setLayoutParams(linearLayoutParams);
cb.setLayoutParams(linearLayoutParams);
bottomAudioLogosLayout.addView(iv);
bottomAudioLogosLayout.addView(cb);
ImageUtil.loadImage(coupon.getImage(), iv, -1, -1, "", false);
}
}
}
}
}, 200);
}
============LoadGutschein 方法:
private void loadGutschein() {
ServiceProxy.createWebServiceTask(getActivity(), new RemoteCallListener() {
@Override
public void onRemoteCallError(String response) {
Log.e("error", "onRemoteCallError is ==>" + response);
}
@Override
public void onRemoteCallComplete(Object response) {
Log.d("debug", "response is = " + response + "\t" + response.getClass());
coupons = (Coupons) response;
Log.d("debug", "coupons = " + coupons);
}
@Override
public void onNoInternetError() {
Log.e("error", "onNoInternetError");
}
@Override
public void onNoAccess() {
Log.e("error", "onNoAccess");
}
}, true, true).invokeGetCoupons();
}
=========我的 LOGCAT 日志:
08-13 14:36:11.382: D/debug(17576): gutscheinName= e
08-13 14:36:11.382: D/debug(17576): gutscheinHN= d
08-13 14:36:11.382: D/debug(17576): gutscheinCash= 50
08-13 14:36:11.382: D/debug(17576): before loadGutschein
08-13 14:36:11.445: D/debug(17576): after loadGutschein
08-13 14:36:11.515: I/WEB-SERVER-CLIENT GET :(17576): http://developer.weinco.de/api/v1/getCoupons?
08-13 14:36:11.648: D/debug(17576): couponsout=null
08-13 14:36:11.742: D/debug(17576): response is = [Coupon [Name=Rabatt, Code=321, GueltigBis=2014-09-01, Typ=absolut, Wert=10, GueltigAb=2011-09-01, Gueltig=alle]] class com.weinco.webservice.entity.Coupons
08-13 14:36:11.742: D/debug(17576): coupons = [Coupon [Name=Rabatt, Code=321, GueltigBis=2014-09-01, Typ=absolut, Wert=10, GueltigAb=2011-09-01, Gueltig=alle]]
我不明白为什么 postDelayed(logcat 中的优惠券)中的优惠券值为空,如果来自 web 服务的优惠券采用响应的价值。任何想法我怎么能解决这个问题?