How to implement first launch tutorial like Android Lollipop apps: Like Sheets, Slides app?

前端 未结 7 1410
[愿得一人]
[愿得一人] 2020-12-04 05:42

I have Android 5.0 final build flashed in my Nexus 5. I noticed it has very beautiful, clean and elegant way of showing tutorial at first launch. Apps like \"Sheets\", \"Sli

7条回答
  •  暖寄归人
    2020-12-04 06:16

    You can use ViewPagerIndicator here: http://viewpagerindicator.com/#download. Then, you should define SharedPreferences, to show that ViewPager only once. You can write:

    public class MainActivity extends Activity {
        public static final String MyPrefs = "MyPrefs";
        ...
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            SharedPreferences sp = getSharedPreferences(MyPrefs, Context.MODE_PRIVATE);
            if (!sp.getBoolean("first", false)) {
                SharedPreferences.Editor editor = sp.edit();
                editor.putBoolean("first", true);
                editor.commit();
                Intent intent = new Intent(this, SampleCirclesDefault.class); //call your ViewPager class
                startActivity(intent);
            }
        }
    }
    

提交回复
热议问题