I. Interface implementation:
drawing on other people's examples, and then record the implementation of the Guide interface, the overall implementation is not difficult, the premise is to have an art to help you do these guided pictures (find a picture to use it):
Main interface:
public class Mainactivity extends Promptactivity { //activity life cycle public void onCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Setguideresid (R.DRAWABLE.PROMPT2);// Add a Boot page}}
Boot interface:
public class Promptactivity extends Activity {private int guideresourceid = 0;//Boot page picture resource idprivate promptsharedpreferences psp; @Overrideprotected void OnStart () {Super.onstart (); Addguideimage ();//Add Boot page}//show boot picture public void Addguideimage () { PSP = new Promptsharedpreferences (); View view = GetWindow (). Getdecorview (). Findviewbyid (R.id.my_content_view);//Find the root layout via Setcontentview if (view = = null) Return;if (Psp.takesharedpreferences (this)) {//have function boot, jump out of return;} Viewparent viewparent = View.getparent (); if (viewparent instanceof framelayout) {final Framelayout FrameLayout = (FrameLa yout) viewparent;if (Guideresourceid! = 0) {//Set boot picture final ImageView guideimage = new ImageView (this); Framelayout.layoutparams params = new Framelayout.layoutparams (ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); Guideimage.setlayoutparams (params); Guideimage.setscaletype (Scaletype.fit_ XY); Guideimage.setimageresource (Guideresourceid); Guideimage.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View v) {//delete boot picture framelayout.removeview (guideimage);//Save Record Psp.savesharedpreferences ( Promptactivity.this, "Started");}); Framelayout.addview (guideimage);//Add the boot picture}}}//get the picture idprotected void Setguideresid (int resId) {This.guideresourceid = ResId;}}
Layout:
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:orientation=" vertical " android:layout_width=" fill_parent " android:layout_height=" Fill_parent " android:id=" @id/my_content_view " > <textview android:layout_width=" Fill_ Parent " android:layout_height=" wrap_content " android:layout_margintop=" 58DP " android:layout_ marginleft= "150DP" android:text= "haha" /> <textview android:layout_width= "Fill_ Parent " android:layout_height=" wrap_content " android:layout_margintop=" 58DP " android:layout_ marginleft= "275DP" android:text= "Ha" /></relativelayout>
Local Files:
public class Promptsharedpreferences {private sharedpreferences sp;//save public void Savesharedpreferences (Context Context, String Save) {sp = Context.getsharedpreferences ("Prompt", context. Mode_private); Editor editor = Sp.edit (); Editor.putstring ("state", save); Editor.commit ();//Save new data}//Remove public boolean Takesharedpreferences (Context context) {String str = ""; sp = Context.getsharedpreferences ("Prompt", context. mode_private), str = sp.getstring ("state", ""), if (Str.equals ("")) {return false;} else{ return True;}}}
Add Values/ids.xml:
<?xml version= "1.0" encoding= "Utf-8"? ><resources><item type= "id" name= "my_content_view" ></ Item></resources>
Android Feature Boot interface implementation