What is the viewholder of "android development experience"? Static Final Static final?

Source: Internet
Author: User
<span id="Label3"></p><p><p>In fact, I put a picture on the ok, because these kinds of exactly the same, no matter what decoration, Viewholder will initialize the current interface to see the number of item + 1 times, and the Convertview number of instances is the same, so I do not use any decoration is not a problem, is not necessary.</p></p><p><p>Static modifier class, Here is the static inner class, is not to say that there is only one instance, but can access the static variables of the external class, the final decorated class is not allowed to inherit the class, we use final no basis here, so, later write viewholder, can not tangle, Add what add ah, do not add anything!</p></p><p><p></p></p><p><p></p></p><p><p>----------------------------------------------------------------------------------------</p></p><p><p>Today he consulted the company a great god, his answer is as Follows:</p></p><p><p>This article does not mention the timing of loading Issues. In my understanding: the main function of the static inner class is whether the inner class needs to isolate the "this object (pointer) of the outer class". The inner class has the this pointer and can "direct" access to the member variables and member functions (including private members) of the external class. The static inner class, without this pointer, cannot be called "directly".<br><br>Personal habits, I usually put internal static classes as a separate Java file.<br><br>But the builder,layoutparams that are often used in Android code exist in the form of static internal Classes. We can follow the actual use of the Following.<br><br>It is also important to mention that internal static classes (especially private internal static classes) work better in code Obfuscation. Will increase the difficulty of Anti-compilation.<br><br>-------------------------------------------------------<br>For this article, i understand. The construction and reuse of viewholder, and static static is not Closed. The core is the ListView (adapterview), and the ViewGroup of GetView (int position, View convertview, Convertview Parent) will pass in a reusable object to the Developer. Developers need to use this object to reduce the consumption of application Memory.<br><br><br>If you are starting from an angle that reduces memory consumption. I think viewholder should still be modified to be static better. In this way viewholder can reduce the Mainactivity's this pointer, which reduces the reference count for mainactivity due to the reduction of a reference to this pointer. Mainactivity's this pointer inherits from the context of Android and is a big problem in Android memory management for missing context Recycling. We reduced the reference to the context to make it easier to reduce the problem with the context reference Count.</p></p><p><p>What is the viewholder of "android development experience"? Static Final Static final?</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.