首页 新闻 搜索 专区 学院

手机端功能引导怎么做?

0
悬赏园豆:10 [已解决问题] 解决于 2016-05-19 12:56

刚做前端不久,现在要做一个手机端功能帮助引导,这个怎么做?头大

许你一生情缘的主页 许你一生情缘 | 初学一级 | 园豆:181
提问于:2016-05-06 13:41
< >
分享
最佳答案
0

android ?引导页?

收获园豆:10
威廉姆斯·苑 | 初学一级 |园豆:125 | 2016-05-07 09:58

是啊

许你一生情缘 | 园豆:181 (初学一级) | 2016-05-09 15:24

@许你一生情缘: 

package com.tuopu.activity;

import java.util.ArrayList;

import com.tuopu.R;


import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

public class GuidanceActivity extends Activity implements OnClickListener {
    ViewPager viewpager;
    ImageView ima;
    ArrayList<View> viewlist = new ArrayList<View>();
    private LayoutInflater inflater;
    private Button jump_but;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guidance_activity);
        initViews();
        initEvents();
        viewpager.setAdapter(new PagerAdapter() {

            @Override
            public boolean isViewFromObject(View arg0, Object arg1) {
                // TODO Auto-generated method stub
                return arg0 == arg1;
            }

            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return viewlist.size();
            }

            @Override
            public Object instantiateItem(ViewGroup container, int position) {
                // TODO Auto-generated method stub
                View view = viewlist.get(position);
                container.addView(view);
                return view;
            }

            @Override
            public void destroyItem(ViewGroup container, int position,
                    Object object) {
                container.removeView((View) object);

            }
        });

    }

    protected void initViews() {
        // TODO Auto-generated method stub
        viewpager = (ViewPager) findViewById(R.id.guidance_viewPager);
        viewpager = (ViewPager) findViewById(R.id.guidance_viewPager);
        ima = (ImageView) findViewById(R.id.gurdance_imageView1);
        ima.setImageResource(R.drawable.yindaoye_jiaohudian01);
        jump_but = (Button) findViewById(R.id.jump_but);

        inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        viewlist.add(inflater.inflate(R.layout.introduction_page1, null));
        viewlist.add(inflater.inflate(R.layout.introduction_page2, null));
        viewlist.add(inflater.inflate(R.layout.introduction_page3, null));
        viewlist.add(inflater.inflate(R.layout.introduction_page4, null));
        viewlist.add(inflater.inflate(R.layout.introduction_page5, null));
    }

    protected void initEvents() {
        // TODO Auto-generated method stub
        jump_but.setOnClickListener(this);
        viewpager.setOnPageChangeListener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                // TODO Auto-generated method stub
                if (arg0 == 0) {
                    ima.setImageResource(R.drawable.yindaoye_jiaohudian01);
                } else if (arg0 == 1) {
                    ima.setImageResource(R.drawable.yindaoye_jiaohudian02);
                } else if (arg0 == 2) {
                    ima.setImageResource(R.drawable.yindaoye_jiaohudian03);
                } else if (arg0 == 3) {
                    ima.setImageResource(R.drawable.yindaoye_jiaohudian04);
                    jump_but.setVisibility(View.GONE);
                } else if (arg0 == 4) {
                    ima.setImageBitmap(null);
                    jump_but.setVisibility(View.VISIBLE);
                }

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
                // TODO Auto-generated method stub

            }
        });

    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        SharedPreferences isfirstused = getSharedPreferences("isfirstused",
                MODE_PRIVATE);
        isfirstused.edit().putBoolean("isfirstused", false).commit();

        // 判断是否是已经登陆
        SharedPreferences userinfo = getSharedPreferences("userinfo",
                MODE_PRIVATE);
        Intent intent = new Intent();

        String userid = userinfo.getString("userid", null);
        if (null == userid) {
            intent.setClass(this, LoginActivity.class);
        } else {
            intent.setClass(this, MainActivityBeiYong.class);
        }

        startActivity(intent);
        finish();
    }

}



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layout_bgcolor"
    >

 

    <android.support.v4.view.ViewPager
        android:id="@+id/guidance_viewPager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </android.support.v4.view.ViewPager>
   <ImageView
        android:id="@+id/gurdance_imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="25dp" />
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom">
    <View 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>
       <Button
       android:id="@+id/jump_but"
       android:layout_width="fill_parent"
       android:layout_height="0dp"
       android:background="@null"
       android:visibility="gone"
       android:layout_weight="1"/>
</LinearLayout>


</RelativeLayout>
威廉姆斯·苑 | 园豆:125 (初学一级) | 2016-05-09 15:27

@威廉姆斯·苑: 赞一个!很详细呀。

行走于奋斗之路 | 园豆:251 (菜鸟二级) | 2016-05-14 09:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册