片段中的Android翻译动画无法正常工作

时间:2013-04-29 09:19:00

标签: android animation android-fragments android-animation

我在listviews的片段中创建了一个翻译动画,当我点击该片段页面中的列表项时它正在工作但是,当我访问其他片段并返回并单击列表项时没有动画它不起作用触发,然后我尝试动画监听器只有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;

    }

0 个答案:

没有答案