我在列表视图的片段内创建了一个翻译动画,当我单击该片段页面中的列表项时它正在工作,但是当我访问其他片段并返回并单击未触发动画的列表项时它不起作用,然后我尝试了动画监听器,只有 onAnimationStart() 方法被触发并且 onAnimationEnd() 没有被执行。此外,我在中等版本(如 API 级别 8)中没有遇到这个问题,只有高版本(如 API 级别 14,16,..)给我带来了这个麻烦。我希望有人能帮助我摆脱这个问题..提前谢谢...这是我的代码,
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.my_certificate, container, false);
Log.d("err", "onCreateView");
// setContentView(R.layout.my_certificate);
Constants.passcode_chk = 0;
getReference();
setclick();
DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay()
.getMetrics(displaymetrics);
screenWidth = displaymetrics.widthPixels;
if (resumeFlag == 0) {
new RssLoadingTask_certificate().execute();
} else {
Log.d("err", "onCreateView else");
if (list_no == 1) {
try {
view.refreshDrawableState();
mainListView.clearAnimation();
mainListView.setVisibility(View.GONE);
mainListView.setVisibility(View.VISIBLE);
} catch (Exception e) {
Log.d("Jemshid", "" + e.toString());
}
menuFlag = 0;
lastPos = -1;
animFlag = false;
multi = false;
Animating = false;
tabimage.setImageResource(R.drawable.certificate_active_tab);
setListing(arr_active_voucher);
mainListView.onRefreshComplete();
} else if (list_no == 2) {
mainListView.clearAnimation();
menuFlag = 0;
lastPos = -1;
animFlag = false;
multi = false;
Animating = false;
tabimage.setImageResource(R.drawable.certificate_used_tab);
setListing(arr_used_voucher);
mainListView.onRefreshComplete();
} else if (list_no == 3) {
menuFlag = 0;
lastPos = -1;
animFlag = false;
multi = false;
Animating = false;
tabimage.setImageResource(R.drawable.certificate_expired_tab);
setListing(arr_expire_voucher);
mainListView.onRefreshComplete();
}
}
try {
view.clearAnimation();
view.refreshDrawableState();
} catch (Exception e) {
}
return view;
}
setListing 方法,
private void setListing(ArrayList<Voucher_list> arr) {
// TODO Auto-generated method stub
VoucherData my_data[] = new VoucherData[arr.size()];
for (int i = 0; i < arr.size(); i++) {
ArrayList<Voucher_list> tmpp = arr;
Voucher_list temp = tmpp.get(i);
my_data[i] = new VoucherData(temp.Voucher_dealCertificateTitle,
temp.Voucher_voucherCode, temp.Voucher_dealTypeKey);
}
adapter = new ListVoucherAdapter(mActivity, R.layout.certificate_list,
my_data, arr, mainListView);
adapter.notifyDataSetChanged();
mainListView.refreshDrawableState();
mainListView.setAdapter(adapter);
resumeFlag = 1;
}