整理一下appintro的简单用法
来源:互联网 发布:网络用语皮皮虾 编辑:程序博客网 时间:2024/06/13 13:47
https://github.com/apl-devs/AppIntro/issues/264
在添加之前会出现这样的一个错误。
ArrayIndexOutOfBoundsException需要删除的appintro的oncrate方法中的
PersistentBundle
remove PersistentBundle argument from your OnCreate method.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
https://github.com/apl-devs/AppIntro/wiki/How-to-Use#show-the-intro-once
这是官网的教程。
@0 添加 根目录下的
allprojects { repositories { jcenter() maven { url 'https://jitpack.io' } }}app目录下的
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.github.apl-devs:appintro:v4.2.0'}
@1 生成一个SampleSlide文件。https://github.com/apl-devs/AppIntro/blob/master/example/src/main/java/com/amqtech/opensource/appintroexample/util/SampleSlide.java
import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;public class SampleSlide extends Fragment { private static final String ARG_LAYOUT_RES_ID = "layoutResId"; private int layoutResId; public static SampleSlide newInstance(int layoutResId) { SampleSlide sampleSlide = new SampleSlide(); Bundle args = new Bundle(); args.putInt(ARG_LAYOUT_RES_ID, layoutResId); sampleSlide.setArguments(args); return sampleSlide; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) { layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID); } } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(layoutResId, container, false); }}
@2新建一个引导页文件
import android.os.Bundle;import android.os.PersistableBundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import com.github.paolorotolo.appintro.AppIntro;/** * Created by mt on 6/19/17. */public class appintros extends AppIntro { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addSlide(SampleSlide.newInstance(R.layout.slideone)); addSlide(SampleSlide.newInstance(R.layout.slidetwo)); addSlide(SampleSlide.newInstance(R.layout.slidethree)); // setFadeAnimation(); setFlowAnimation(); showSkipButton(false); // showDoneButton(false); //showSkipButton(false); } @Override public void onSkipPressed(Fragment currentFragment) { super.onSkipPressed(currentFragment); //finish(); } @Override public void onDonePressed(Fragment currentFragment) { super.onDonePressed(currentFragment); finish(); } @Override public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment newFragment) { super.onSlideChanged(oldFragment, newFragment); // finish();//这里需要注释掉
}}
并添加到配置文件中。
@3 主文件让引导页显示一次。
Thread t = new Thread(new Runnable() { @Override public void run() { // Initialize SharedPreferences SharedPreferences getPrefs = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); // Create a new boolean and preference and set it to true boolean isFirstStart = getPrefs.getBoolean("firstStart", true); // If the activity has never started before... if (isFirstStart) { // Launch app intro Intent intent = new Intent(MainActivity.this, appintros.class); startActivity(intent); // Make a new preferences editor SharedPreferences.Editor e = getPrefs.edit(); // Edit preference to make it false because we don't want this to run again e.putBoolean("firstStart", false); // Apply changes e.apply(); } } }); // Start the thread t.start();
@4j最后新建引导页布局文件即可。
阅读全文
0 0
- 整理一下appintro的简单用法
- 整理一下vim命令的基本用法
- 实用的欢迎页开源库 AppIntro
- 整理一下,定时器用法
- 简单谈一下git的用法
- 整理收集了一下linux的find命令的用法
- 经常遇到的一些异常,简单的整理了一下
- 【Java】简单总结一下Java中printf()的用法
- 【Java】简单总结一下Java中printf()的用法
- 简单介绍一下jQuery的一些特性和用法:
- 【Java】简单总结一下Java中printf()的用法
- [原创]简单讲一下类成员函数指针的用法
- 简单说一下jquery中 tmpl 的用法
- 翻翻git之---实用的欢迎页开源库 AppIntro
- 正则的一下用法
- 整理一下XSLT的优缺点
- 整理一下最近的笔记
- 整理一下自己的态度
- phpcms框架的安装教程
- LeetCode 56. Merge Intervals
- mac_beyond_破解
- 在myeclipse中修改工程项目的web context-root
- 精通比特币-第2章 比特币的原理
- 整理一下appintro的简单用法
- 从数组中寻找和的相加数
- 精通比特币-第3章 比特币客户端
- 野指针的定义和避免
- 精通比特币-第4章 密钥、地址、钱包
- 精通比特币-第5章 交易
- 什么是二倍图?什么是三倍图?
- 剑指Offer——在O(1)时间内删除表节点
- DAY-2