- Activity in the Onattachedwindow life cycle after onresume, so the long-width gain is recommended in Onattachedwindow.
- Ondetachedwindow is called after OnDestroy, press the back key to execute, but pressing the home key will not execute.
- 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.
- TextView Singeline will invalidate the color of the custom background.
- 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.
- 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