1

flipperview在 android 中的动画有问题,我正在使用flipperview水平视图动画,arraylist大小为 14,但 getview 调用仅 3 次之后getview()没有调用。

代码是:

@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
public class DetailsActivity extends Activity {

    private FlipViewController flipView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        flipView = new FlipViewController(this, FlipViewController.HORIZONTAL);

        flipView.setAdapter(new BaseAdapter() {

            private WebView mWebview;
            ProgressDialog progressDialog = null;
            List<EventUtil> mEventUtil= GlobalValues.getInstance().eventUtils;
            private int repeatCount = 1;

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View layout = convertView;
                LayoutInflater inflater= LayoutInflater.from(EventDetailsActivity.this);

                if (convertView == null) {
                    layout = inflater.inflate(R.layout.pf_fragment_event_desc, null);

                    progressDialog = Constants.getInstance().loadingDialog(getParent());

                    EventUtil eventDescEntity = mEventUtil.get(position);

                    Log.d("ARRAYSIZE", mEventUtil.size()+"");
                    mWebview = (WebView)layout.findViewById(R.id.event_detail_web_view);
                    mWebview.getSettings().setJavaScriptEnabled(true);
                    getJsonObject(eventDescEntity.getEvent_id(),mWebview);

                    Log.d("POSISSION", position+"");
                }

                return layout;
            }

            @Override
            public long getItemId(int position) {

                return position;
            }

            @Override
            public Object getItem(int position) {

                return position;
            }

            @Override
            public int getCount() {

                return mEventUtil.size() * repeatCount;
            }
        });

        setContentView(flipView);
    }

    @Override
    protected void onResume() {

        super.onResume();
        flipView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        flipView.onPause();
    }
}

它工作正常,问题是当 getView() 方法没有调用之后 getview 计数达到 3

log

position 0
position 1
position 2

计数没有增加请帮帮我。

4

1 回答 1

0

尝试

if (convertView == null) {
    layout = inflater.inflate(R.layout.pf_fragment_event_desc, parent, false);
}

仅当 convertView 为空时,您的代码才会放置信息

(注意:您在这里知道项目的父项将是什么(ViewGroup 父参数),因此您应该使用 inflate(id, parent, false); 而不是 inflate(id, null); 告诉充气机 - 你应该几乎从不调用 inflate(id, null))

查看更多;

布局膨胀文档

于 2013-11-12T00:21:22.730 回答