Android使用ViewPager实现启动引导页效果

本文实例为大家分享了Android实现启动引导页效果的具体代码,供大家参考,具体内容如下

ViewPagerTwoActivity.java

package cn.edu.zufe.app001;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import java.util.ArrayList;

public class ViewPagerTwoActivity extends AppCompatActivity {

    private int[] launchImageArray = new int[]{
            R.drawable.guide_bg1,R.drawable.guide_bg2,R.drawable.guide_bg3,R.drawable.guide_bg4
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_pager_two);
        ViewPager vp_launch = (ViewPager)findViewById(R.id.vp_launch);
        LaunchSimpleAdapter adapter = new LaunchSimpleAdapter(this,launchImageArray);
        vp_launch.setAdapter(adapter);
        vp_launch.setCurrentItem(0);
    }

    class LaunchSimpleAdapter extends PagerAdapter{
        private Context mContext;
        private ArrayList mViewList = new ArrayList();
        public LaunchSimpleAdapter(final Context context, int[] imageArray){
            mContext = context;
            for(int i=0; i 
 

activity_view_pager_two.xml




    
    

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(Android使用ViewPager实现启动引导页效果)