开发者

android ViewFlipper optimiztion

开发者 https://www.devze.com 2023-03-09 05:19 出处:网络
I am making an quiz app, because I am getting all the quizes from a web service, what I am doing now, is to download all the quiz, parse the开发者_开发技巧m into quiz objects, push all the objects int

I am making an quiz app, because I am getting all the quizes from a web service, what I am doing now, is to download all the quiz, parse the开发者_开发技巧m into quiz objects, push all the objects into a quiz ArrayList, and loop through the ArrayList to add everything into the ViewFlipper when onCreate, something like this:

vf = (ViewFlipper) findViewById(R.id.viewFlipper);
for (MyQuiz q : qz.myQuizList) {
     vf.addView(q.getView(CURRENT_ACTIVITY));
}

The problem is, within each of my view, I have a lot of stuff going on(including WebView and many pictures). So I am wondering if there is a way that I could adopt to optimize memory usage by somehow not creating all the activities before I even need them, but creating them on demand for ViewFlipper? Like what ListView is handled. I may have a background data set, when I need a range of data to be displayed, I then only transform that amount of data into activities to display. Anyone knows how to achieve this? Thanks a lot.


I guess you could wait until each of the 'flips' are displayed to initialize each view. Before you flip the view, find the next view and set it up. You might want a dynamic list of ID's so that you can manage which view you are currently viewing.


This might be helpful http://tech.favoritemedium.com/2011/07/viewflipper-and-bitmaps-in-android-30.html

0

精彩评论

暂无评论...
验证码 换一张
取 消