In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the methods of Android development project". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the methods of Android development project".
1. Should you put the data refresh operation in onResume ()?
@ Override public void onResume () {super.onResume (); refresh ();} public void refresh () {initData ();}
This is not appropriate. When the refresh comes on demand, it does not need to be refreshed every time onResume ().
If the user closes the screen and then opens the screen, the page will refresh, which is not necessary. It may have just been refreshed a few seconds ago.
NetEase news client is not like this.
two。 About activity,fragment and pop-up window
If two fragment are loaded in a ViewPager,ViewPager in an activity, it is important to note that the two fragment are loaded by a colleague, although only one fragment interface is displayed, but the other one is also loaded, so if the currently displayed fragment does not have a pop-up window, another fragment pop-up window will also be displayed in the current activity.
Advantages and disadvantages of 3.copy layout files and reused layout files
Reuse advantage: reduce the number of layout files, if the layout of several interfaces is always the same, then you can use the
Reuse disadvantage: if one of the layout files changes, the other pages will no longer be available because if else cannot be used in the layout file.
Copy advantages: a page corresponds to a xml file, completely decoupled
Copy disadvantage: there will be a lot of duplicate code
Conclusion: the demand may change at any time, so it is better to decouple the layout.
4. The idea of optimizing the Code
The higher the frequency of which code is used, which code should be optimized first, it will get twice the result with half the effort!
5. Be sure to protect your code.
Yesterday, he told me that the interface of the so-and-so module had changed. I wanted to do it again. I did it.
When I came here today, I told me that I would not change it for the time being, but still use the previous code.
Oh, my God, it's a good thing I didn't delete the previous code, otherwise I would have died.
So, programmers, protect your own code.
6. It will be tragic if the template method is not well written.
Template method is written, such as BaseAcitivity, and then start to write its subclass, suddenly debug found that there is something wrong with the template method, such as to adjust the order of method calls or change the location of method calls, which is good, your N subclasses are written in accordance with the previous template method, so you go to modify the subclass one by one.
In addition, be careful that others have modified the common template methods, and pull and push code in time, otherwise a lot of your own code will be wasted.
7. Do not repeat the call data frequently
For example, if you want to get 10-news list data, and you want to get it at the same time, you have to create 10 Http links, which is very time-consuming. The way to * is to have the server write 10 news list data in a xml file, which will significantly save time. Wo
So, when making remote calls, getting data from a data provider repeatedly can seriously affect performance, such as database calls, Web service calls, or other codec calls. In this case, the Facade mode can be used to obtain all the required data at once, minimizing the connection cost and the cost of transmitting data over the network.
8. Prefix "m" to the member variable in the class
All member variables of this class are preceded by "m". The advantage is that typing "m" can prompt some member variables of this class.
9. Be sure to have your own technical blogs and posts
Other people's blogs and posts are other people's, should have their own, constantly supplement, constantly improve, later when it is convenient to check.
In addition, to force yourself to write technical blogs and posts is to force yourself to summarize and deepen the impression of technical knowledge.
10. A class should be pure, and a class should only do one thing.
For example, write a waterfall flow class (custom View), do a lot of things, layout the waterfall flow model, set up the refresh function.
This should not appear in a class, waterfall flow is waterfall flow, refresh is another thing, getting data is another matter! Don't mix it up, write it in one class!
A class should be pure, as simple as possible, that is, to do one thing. To complete a function, we can combine multiple classes, or reference methods, and so on.
The advantage is that it is easy to disassemble and can be stripped off quickly and clearly when no function is needed. If all the code is mixed together, it is often difficult to peel off.
Thank you for your reading, these are the contents of "what are the methods of Android development projects?" after the study of this article, I believe you have a deeper understanding of what the methods of Android development projects have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.