Android Recent experience finishing

Source: Internet
Author: User

  1. Activity in the Onattachedwindow life cycle after onresume, so the long-width gain is recommended in Onattachedwindow.
  2. Ondetachedwindow is called after OnDestroy, press the back key to execute, but pressing the home key will not execute.
  3. The fragment tag in XML can only be fragment in the Android.support.v4 package and inherits from subclasses of that class, otherwise it will be quoted as "binary XML file line #6: Error inflating class Fragment "error, if you want to use more than 3.0 version of the fragment recommendation is to define a container in XML, and then use the Fragmenttransaction operation container, add fragment.
  4. TextView Singeline will invalidate the color of the custom background.
  5. The best solution for EditText control is to set the value of enable to control, which is much better than adjusting or replacing the control by code.
  6. Listen for keyboard bounce and hide events, The recommendation is to set Adjustpan or adjustresize in the windowsoftinputmode of the activity androidmanifest.xml, depending on what kind of environment you use, and then register for monitoring Viewtreeobserver. Ongloballayoutlistener, in the overloaded method ongloballayout to determine whether the bounce or hide. The sample code is as follows:
    Private class Mystatelistener implements Viewtreeobserver.ongloballayoutlistener {private final View mdecorview;        Private final camerafragment mfragment;        private int mframeheight = 0;        Private Boolean mkeyboardshow;        Private final Rect Mvisibledisplayframe;            Imestatelistener (camerafragment paramview, view view) {this.mfragment = Paramview;            This.mdecorview = view;        This.mvisibledisplayframe = new Rect (); } @Override public void Ongloballayout () {This.mDecorView.getWindowVisibleDisplayFrame (mvisibled            Isplayframe);            int i = This.mVisibleDisplayFrame.height ();            if (This.mframeheight = = 0) {this.mframeheight = i;            } if (I < this.mframeheight) {this.mkeyboardshow = true;                } else if (this.mkeyboardshow) {this.mkeyboardshow = false;   Mhandler.sendemptymessage (Keyboard_hide);         }        }    } 



Android Recent experience finishing

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.