Typical collection of Android development tips

Source: Internet
Author: User

DateUtils. formatDateTime () -- provides an all-in-one service for formatting time/date strings in a region.

AlarmManager. setInexactRepeating-saves power by means of alarm grouping. Even if you only call one alarm instance, it is still easy to use and can automatically call AlarmManager. cancel () after use ().

Formatter. formatFileSize () -- a regionalized file size formatting tool.

ActionBar. hide ()/. show () -- animations can be displayed when the actionBar is displayed or hidden. It can be more elegant when switched to full screen.

Linkify. addLinks () -- you can add links to Text.

StaticLayout -- it is useful when rendering text in a custom View.

Activity. onBackPressed () -- convenient control of the return button, which can be used when you need to customize the return key operation.

GestureDetector-monitors action events and related listener events such as click, scroll, and slide ). It is simpler than implementing some action events of the system.

DrawFilter -- allows you to operate the Canvas, even if the draw method is not called. For example, you can set a DrawFilter when creating a custom View and set an anti-alias for all views in the parent View.

ActivityManager. getMemoryClass () -- Let You Know How much memory is left on the device. It is useful when calculating how to set the cache size.

SystemClock. sleep ()-This method is convenient to ensure sleep for a certain period of time. It is usually used to debug and simulate network latency.

ViewStub -- it is a View that does not do anything during initialization, but can then load a layout file. It is suitable for placeholders in slow loading views. The only drawback is that tags are not supported. Therefore, if you are not careful, unnecessary nesting may be added to the view structure.

DisplayMetrics. density -- this method can be used to obtain the screen density. In many cases, you need to remove the function of auto scaling, but sometimes it is useful when controlling, especially when customizing the View ).

Pair. create () -- easy to build methods for classes and constructors.

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.