Ok so I am writing a game that has a shop. The shop is where i am having problems because each item in the shop has several stats and then 2 buttons and an edit text for buying/selling.
The layout for the shop has 3 tabs with 26 items in each tab and that totals to: 130 ImageViews, 364 TextViews, 52 Buttons, and 26 EditTexts per tab. So if you keeping count that is a total of 1,768 views in one 3 tabbed layout. (I know, "HOLY CRAP!")
I wasn't really thinking about efficiency as I was writing this section and now I find that loading this activity takes on average 3-5 seconds or more. I want it to load quicker but I like the layout and the general "look and feel" of the shop as it is.
I have already broke up the listeners so that it is only listening to the elements in the current tab and turns off the listeners for the inactive tabs. This helped a little but i don't think that was a major aspect of the problem.
Can anyone suggest anything else I can do to help the loading time on this activity?
EDIT: Screenshot. I have heard something about a r开发者_如何学Cecycler? What is that and would it apply here to help loading times?
I've had a similar issue in designing complex dialogs. Basically the number of things that need to be displayed at one time is not much, but the number of things that might be displayed, over all possibilities, could be prohibitively large.
I made a domain-specific-language for coding complex dialogs, discussed here, and basically, the way it addresses your problem is it makes/destroys objects on-the-fly as they are needed. One might feel that this would be costly in terms of performance, but it really isn't, and the benefit of not tying up memory with things that might be displayed but probably won't is pretty significant.
精彩评论