Experience added to Android knowledge points after completing the first Android Project

Source: Internet
Author: User

First, the Framework layout is one of the simplest and most efficient layout types. The child widget of the frame layout is drawn relative to the upper left corner of the layout. If multiple child views exist in the frame layout, they are drawn sequentially, And the last child control is drawn at the top.
Example :.

Second, I used to build the j2-based platform. In order to achieve the effect of running the horse and lights, the implementation method was to constantly refresh the UI thread (drawing thread) and achieve the animation effect by changing the coordinates. At that time, I saw various eye-catching animations on Android, and I was scared. Later I made an Android platform and realized that my urine would be healthier. On the Android platform, the animation effect is encapsulated very well. There are two simple animation models: tweened (transparent/Scalable/moving/rotating) and frame, the download link below has the demo of these two types of Animation: http://download.csdn.net/detail/coding_or_coded/4367757

Third: Android platform gallery can achieve great image drag effect, Demo: http://download.csdn.net/detail/coding_or_coded/4368287

Fourth: implements a very good sharedpreferences encapsulation class.
 

Package COM. IMO. util; import android. content. context; import android. content. sharedpreferences; import android. content. sharedpreferences. editor; import COM. IMO. global. imoapp; /*** sharedpreference encapsulation */public class preferencemanager {/*** save data in the specified file ** @ Param filename * file name * @ Param objs * Array {key, value} */public static void save (string filename, object [] objs) {try {sharedpreferences sp = imoapp. getapp (). getsharedpreferences (filename, context. mode_append); // imoapp. getapp () stands for applicationeditor editor = sp. edit (); If (objs [1] instanceof string) {editor. putstring (objs [0]. tostring (), objs [1]. tostring ();} else if (objs [1] instanceof integer) {editor. putint (objs [0]. tostring (), integer. parseint (objs [1]. tostring ();} else if (objs [1] instanceof long) {editor. putlong (objs [0]. tostring (), long. parselong (objs [1]. tostring ();} else if (objs [1] instanceof float) {editor. putfloat (objs [0]. tostring (), float. parsefloat (objs [1]. tostring ();} else if (objs [1] instanceof Boolean) {editor. putboolean (objs [0]. tostring (), Boolean. parseboolean (objs [1]. tostring ();} editor. commit ();} catch (exception e) {e. printstacktrace () ;}}/*** read data from the specified file ** @ Param filename * file name * @ Param objs * Array {key, defaultvalue} */public static object get (string filename, object [] objs) {try {sharedpreferences sp = imoapp. getapp (). getsharedpreferences (filename, context. mode_append); If (objs [1] instanceof string) {return sp. getstring (objs [0]. tostring (), objs [1]. tostring ();} else if (objs [1] instanceof integer) {return sp. getint (objs [0]. tostring (), integer. parseint (objs [1]. tostring ();} else if (objs [1] instanceof long) {return sp. getlong (objs [0]. tostring (), long. parselong (objs [1]. tostring ();} else if (objs [1] instanceof float) {return sp. getfloat (objs [0]. tostring (), float. parsefloat (objs [1]. tostring ();} else if (objs [1] instanceof Boolean) {return sp. getboolean (objs [0]. tostring (), Boolean. parseboolean (objs [1]. tostring ();} catch (exception e) {e. printstacktrace ();} return NULL ;}}

Related Article

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.