How to save time and effort in Android development, classes, interfaces

Source: Internet
Author: User

Http://www.toutiao.com/i6362292864885457410/?tt_from=mobile_qq&utm_campaign=client_share&app=news_ Article&utm_source=mobile_qq&iid=6611409663&utm_medium=toutiao_android

  1. GetParent (). Requestdisallowintercepttouchevent (True);
    • Explanation: A single click event is passed from the parent view to the child view, each layer of view can decide whether to intercept and handle the click event or pass to the next layer, if the child view does not handle the Click event, then the event will pass the parent view, by the parent view to decide whether to handle the Click event. In child view You can set this method to tell the parent view not to intercept and handle the click event, and the parent view should accept the request until the end of the Click event.
  2. Argbevaluator.evaluate (float fraction, object Startvalue, Object Endvalue);
    • Explanation: Used to generate a new color based on a starting color value and an end color value and an offset, the minute-by-minutes implementation resembles the bottom bar sliding color gradient.
  3. Bitmap.extractalpha ();
    • Explanation: Returns the alpha value of a new bitmap,capture original image. Sometimes we need to dynamically modify the background image of an element and do not want to use more than one picture, through this method, combined with canvas and paint can dynamically modify a solid color bitmap color.
  4. Handlerthread
    • Instead of the repetitive physical notation of the new thread.
  5. Intentservice
    • A service that can kill itself and not need us to manage a child thread.
  6. Palette
    • 5.0 added can extract a bitmap in the highlighted color of the class, combined with the above bitmap.extractalpha.
  7. Executors. Newsinglethreadexecutor ();
    • This is Java, I did not know it before, I spent a lot of effort to study the single-threaded sequential execution of the task queue.
  8. Viewdraghelper
    • Handles various events when customizing a child view to drag and drop viewgroup.
  9. Gradientdrawabl
    • It is used to set gradients in various styles.
  10. Asyncqueryhandler
    • If you do the development of system tools, such as contact SMS AIDS, and so on, it is inevitable to deal with ContentProvider, if the amount of data is not very large, casual, if the volume of data is large, it is necessary to understand the next class.
  11. Viewflipper
    • Enables multiple view transitions (loops) to customize animation effects and specify animations for individual transitions.
  12. View.setlayertype (View.layer_type_software, NULL)
    • Explanation: A friend mentioned that there are some methods in the custom view when the hardware acceleration is not effective, after API16 there are many methods do not support hardware acceleration, usually we turn off hardware acceleration is in the manifest file, In fact, Android also provides a way to turn off hardware acceleration for a particular view, call this method.
  13. Pair
    • The pair class in the Android Util package can be conveniently used to store a "group" of data. Note that it is not key value.
  14. PointF
    • A class in the graphics package, we often see defining a downx when dealing with touch events, a downy used to store a coordinate, and if the coordinates are small enough, the code is not good to read if you want to record too many coordinates. Using pointf (float x, float y) to describe a coordinate point is much clearer.
  15. Statelistdrawable
    • The usual way to define selector is the XML file, but sometimes our picture resources may be dynamically obtained from the server, such as many apps so-called skin, this time can only pass statelistdrawable to complete, a variety of addstate can be.
  16. Android:descendantfocusability
    • In addition to setting the focusable for the corresponding element, it is simpler to add android:descendantfocusability= to the item root layout when the item in the ListView item has the focus of a checkbox such as the grab focal point, which is not responsive. "Blocksdescendants" android:duplicateparentstate= "true" to let the child view follow the state of its parent, such as pressed. A common usage scenario is when a button is small, and we want to expand the area of the click to give it a layer of layout, write the Click event to the parent, and if you want the selector of the click Effect of the Parcel button to continue to take effect, This is where Duplicateparentstate comes in handy.
  17. Includefontpadding= "false"
    • TextView default up and down is a certain padding, sometimes we may not need to leave the upper and lower part of the white, plus it can.
  18. Messenger
    • Inter-process communication.
  19. Textview.seterror ();
    • Explanation: Used to validate user input.
  20. Viewconfiguration.getscaledtouchslop ();
    • Explanation: The minimum distance to trigger the move event, when customizing the View processing touch event, sometimes it is necessary to determine whether the user really exists in the movie, the system provides such a method.
  21. Valueanimator.reverse ();
    • Explanation: Smooth cancellation of animation effects.
  22. Viewstub
    • Sometimes a region needs to show a different layout depending on the situation, usually we will show and hide the different layouts by setvisibility, but this is all loaded by default, and viewstub can better improve performance.
  23. Ontrimmemory
    • Overriding this method in activity will call back when memory is tight (multiple levels are supported), allowing us to proactively release resources and avoid oom.
  24. Edittxt.setimeoptions
    • When using EditText to eject the soft keyboard, modify the display of the ENTER key.
  25. Textview.setcompounddrawablepadding
    • The code sets TextView drawable padding.
  26. Imageswitcher
    • A class that can be used to make a picture switch, similar to a slideshow.
  27. Weakhashmap
    • Using HashMap directly sometimes poses a risk of memory overflow, using Waekhashmap to instantiate a map. When the user no longer has an object reference, Weakhashmap will automatically be removed from the object that corresponds to the key value.

How to save time and effort in Android development, classes, interfaces

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.