1. Press the return key in the interface to determine the visibility of a control, if visible, animate it to disappear, and the app does not exit.
In the OnKeyDown method:
if (keycode = = 4) {
if (slidingmenu.getvisibility () = = view.visible) {
Exiting animations
Animationset animationset = new Animationset (true);
translateanimation animation = new Translateanimation (0,-280, 0, 0);
Animation.setduration (500);
Animationset.addanimation (animation);
Slidingmenu.startanimation (Animationset);
Slidingmenu.setvisibility (View.gone);
return true; If the control is visible in the interface, press the back key to make it disappear, and the app does not exit
}
}
2. Delay jump in Control interface
public class Welcomeactivity extends activity{
Private Handler Mhandler = new Handler () {
public void Handlemessage (Android.os.Message msg) {
Gomain ();
}};
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.welcome);
}
@Override
protected void Onresume () {
Super.onresume ();
Mhandler.sendemptymessagedelayed (0, 3000);
}
/**
* Skip to main interface
*/
private void Gomain () {
Intent Intent = new Intent (welcomeactivity.this, Mainactivity.class);
StartActivity (Intent);
This.finish ();
}}
3. Get screen width and height
Displaymetrics dm = new Displaymetrics ();
This.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);
ScreenWidth = Dm.widthpixels;
ScreenHeight = Dm.heightpixels;
The difference between the 4.private protected public
Public
Public, plus this modified class or attribute, can be accessed in the same package or in another package
Private
Private, with this modified class or attribute, can only be accessed in the same category, the same package and other packages cannot be accessed
Protected
Protection, plus this decorated class or attribute, can only be accessed in homogeneous and identical packages, other packages cannot access