Android App First Use welcome interface instance

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">First of all the use of the Project (flirt 1.0 version of Sugar) source, shared to everyone, novice do not spray. The UI is not learning, using the default theme style, and so on learning to play the UI is doing Updates. This time to do this get a new skill: android. 9 picture Maker. This is not the original contact, feel good on the big thing. Want to know the Self-baidu bar, is a simple operation.</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">SOURCE Address:<span style="font-family: 宋体, SimSun; font-size: 18px; line-height: 26px; color: rgb(0, 176, 80); background-color: rgb(255, 255, 255);">Https://git.oschina.net/zhengweishan/Android_robot</span></span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">There will be time to develop new features Later.</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">Go to two articles first:</span></p></p><p><p><span style="color: rgb(0, 176, 80);">http://blog.csdn.net/wsscy2004/article/details/7611529</span></p></p><p><p><span style="color: rgb(0, 176, 80);">http://blog.csdn.net/x605940745/article/details/23381443</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">What I want to achieve is to:</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">After the program is installed, the first time starts:</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">Start Page-features Introduction Page (multi-image)-system Home</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">Start Later:</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">Start Page-welcome Interface-system Home</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">so make a judgment on the start page,</span> <span style="font-family: 宋体, SimSun; font-size: 14px;">can get a file to save a state, recommended to use Sharedpreferences. </span></p></p><p><p><span style="font-size: 14px;">Compare two blog post feel the second best for me, and then take it directly, here also for their own record, the original thread to achieve a</span></p></p><p><p><span style="font-size: 14px;"><span style="font-size: 14px; color: rgb(0, 176, 80);">http://my.oschina.net/zhengweishan/blog/370983</span></span></p></p><p><p><span style="font-size: 14px;">Only one picture can be loaded the user experience is not good, so this time with this multi-graph guide form.</span></p></p><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;">Main Code:</span></p></p><pre class="brush:java;toolbar: true; auto-links: false;">package com.example.robot;import java.util.arraylist;import java.util.list;import  com.example.robot.adapter.welcomepageadapter;import android.app.activity;import  android.content.context;import android.content.intent;import android.content.sharedpreferences; import android.content.sharedpreferences.editor;import android.os.bundle;import  android.os.handler;import android.support.v4.view.viewpager;import  android.support.v4.view.viewpager.onpagechangelistener;import android.util.log;import  Android.view.view;import android.view.viewgroup;import android.view.viewgroup.layoutparams;import  android.view.ViewTreeObserver.OnPreDrawListener;import android.view.animation.TranslateAnimation; import android.widget.imageview;import android.widget.imageview.scaletype;public class  welcomeactivity extends activity {//  Welcome picture of the first Use program display private int[] ids =  {&nbsp r.drawable.welcome_1, r.drawable.welcome_2, r.drawable.welcome_3, r.drawable.welcome_4 }; private sharedpreferences share;private list<view> guides = new  arraylist<view> ();p rivate viewpager pager;//  Bottom small picture private imageview curdot;//   Displacement private int offset;//  Record the current position private int curpos = 0;private  editor editor; @Overridepublic  void oncreate (bundle savedinstancestate)  { Super.oncreate (savedinstancestate); share = getsharedpreferences ("showwelcome",  Context.MODE_ PRIVATE), Editor = share.edit ();//  Determine if the first login program if  (share.contains ("shownum"))  { Setcontentview (r.layout.welcomes); int num = share.getint ("shownum",  0); editor.putInt (" Shownum ",  num++); editor.commit (); skipactivity (1);}  else {editor.putint ("shownum",  1); editor.commit (); setcontentview (r.layout.welcome); Initview ();}} Private void initview ()  {for  (int i = 0; i < ids.length;  i++)  {//  Create a Imageviewimageview iv = new imageview (this); Iv.setimageresource (ids[i]); Layoutparams params = new layoutparams (layoutparams.match_parent, layoutparams.match_ PARENT); iv.setlayoutparams (params); iv.setscaletype (scaletype.fit_xy); guides.add (iv);} curdot =  (ImageView)  findviewbyid (r.id.cur_dot);//  bind callback Curdot.getviewtreeobserver (). Addonpredrawlistener (new onpredrawlistener ()  {public boolean onpredraw ()  {offset  = curdot.getwidth (); return true;}); /  Initialize Adapterwelcomepageadapter adapter = new welcomepageadapter (guides);p ager =   (viewpager)  findviewbyid (r.id.showwelcome_page);p ager.setadapter (adapter); Pager.setonpagechangelistener (new onpagechangelistener ()  {public void onpageselected (Int arg0)  {movecursorto (arg0);if  (arg0 == ids.length - 1)  {//  To the last one skipactivity (2);} curpos = arg0;} public void onpagescrolled (int arg0, float arg1, int arg2)  {}public  void onpagescrollstatechanged (int arg0)  {}}); /** *  move the pointer to the adjacent position  *  *  @param  position *      Index value of the         pointer  */private void movecursorto (int position)  {translateanimation anim = new translateanimation (offset * curPos,  offset * position, 0, 0); anim.setduration (+); Anim.setfillafter (true); Curdot.startanimation (anim);} /** *  delay how many seconds into the main interface  *  *  @param  min *              sec  */private void skipactivity (int min)  {new  HandLer (). postdelayed (new runnable ()  {@Overridepublic  void run ()  {intent intent  = new intent (welcomeactivity.this, mainactivity.class); startactivity (Intent); WelComeActivity.this.finish ();}}, 1000 * min);}}</pre><p><p> <span style="font-family: song body, simsun; font-size:14px;"> picture loaded adapter </span> </p> </p><pre class="brush:java;toolbar: true; auto-links: false;">Package com.example.robot.adapter;import java.util.list;import android.os.parcelable;import  android.support.v4.view.PagerAdapter;import android.support.v4.view.ViewPager;import  Android.view.view;public class welcomepageadapter extends pageradapter{private list <View> views;          public  Welcomepageadapter (list<view> views) {           this.views=views;      }              @Override       public void destroyitem (view  Arg0, int arg1, object arg2)  {            ((viewpager)  arg0). Removeview (views.get (arg1));      }          @Override        public void finishupdate (view arg0)  {       }         @Override        public int getcount ()  {          return  views.size ();       }        @ Override      public object instantiateitem (View arg0, int  arg1)  {           ((viewpager)  arg0). AddView ( Views.get (arg1),  0);           return views.get ( arg1);      }         @Override        public boolean isviewfromobject (view arg0, object arg1)  {          return arg0 ==  (arg1);       }          @Override       public void  restorestate (parcelable arg0, classloader arg1)  {                 }          @Override       public parcelable savestate ()  {           return null;      }          @Override       public void  Startupdate (view arg0)  {                 }  }</pre><p><p><span style="font-family: 宋体, SimSun; font-size: 14px;"><br></span><br></p></p><p><p><br></p></p><p><p>Android App First Use welcome interface instance</p></p></span>

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.