Android学习总结——欢迎页和导航页的实现
activity_welcome.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.sssss.fllm.Welcome"> <ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:scaleType="fitXY"
android:src="@drawable/welcome"
/>
</LinearLayout>
activity_guide.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sssss.fllm.Guide"> <android.support.v4.view.ViewPager
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/viewPage"/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:id="@+id/ll"> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv1"
android:src="@drawable/login_point_selected"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv2"
android:src="@drawable/login_point"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/iv3"
android:src="@drawable/login_point"/> </LinearLayout> </RelativeLayout>
view1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:background="@drawable/guide_1"/>
</LinearLayout>
view2.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView2"
android:background="@drawable/guide_2"/>
</LinearLayout>
view3.xml
<?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"> <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView3"
android:background="@drawable/guide_3"/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" > </LinearLayout> <Button
android:id="@+id/btnStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击进入>>>"
android:layout_marginBottom="41dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" /> </RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sssss.fllm">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/kunyi"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
mipmap
<activity
android:name=".Welcome">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Guide"></activity>
</application> </manifest>
Welcome.java
package com.example.sssss.fllm; import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle; public class Welcome extends Activity {
//设置延时时间
private static final int TIME=2000;
//通过参数来决定跳转哪一个界面
private static final int GO_KYTeach=1000;
private static final int GO_GUIDE=1001;
//判断handler发送了什么消息
private boolean isFirstIn=false; //等待的时间不能让其在主线程中沉睡,应通过Handler来进行沉睡
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what){
case GO_KYTeach:
goHome();
break;
case GO_GUIDE:
goGuide();
break;
}
}
}; private void init(){
//获取
SharedPreferences perferences=getPreferences(MODE_PRIVATE);
isFirstIn=perferences.getBoolean("isFirstIn",true);
if(!isFirstIn){
handler.sendEmptyMessageDelayed(GO_KYTeach,TIME);
}else {
handler.sendEmptyMessageDelayed(GO_GUIDE,TIME);
//储存
SharedPreferences.Editor editor=perferences.edit();
editor.putBoolean("isFirstIn",false);
//提交
editor.commit();
}
} public void goHome(){
}
public void goGuide(){
Intent intent=new Intent(Welcome.this,Guide.class);
startActivity(intent);
finish();
} @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
init();
} }
Guide.java
package com.example.sssss.fllm; import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
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 java.util.ArrayList;
import java.util.List; public class Guide extends Activity implements ViewPager.OnPageChangeListener { private Button btnStart;
private ViewPager viewPager;
private View view1, view2, view3;
private List<View> viewList;//view数组
private PagerAdapter pagerAdapter;
private ImageView[] dots;
private int[] ids={R.id.iv1,R.id.iv2,R.id.iv3}; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guide); pagerAdapter = new PagerAdapter(){ @Override
public int getCount() {
return viewList.size();
} @Override
public boolean isViewFromObject(View view, Object object) {
return view==object;
} @Override
public void destroyItem(ViewGroup container, int position, Object object) {
//super.destroyItem(container, position, object);
container.removeView(viewList.get(position));
} @Override
public Object instantiateItem(ViewGroup container, int position) {
//return super.instantiateItem(container, position);
container.addView(viewList.get(position));
return viewList.get(position);
}
}; initView();
initDots();
} public void initView(){
viewPager= (ViewPager) findViewById(R.id.viewPage);
LayoutInflater inflater=getLayoutInflater().from(this);
view1 = inflater.inflate(R.layout.view1, null);
view2 = inflater.inflate(R.layout.view2,null);
view3 = inflater.inflate(R.layout.view3, null); viewList = new ArrayList<View>();// 将要分页显示的View装入数组中
viewList.add(view1);
viewList.add(view2);
viewList.add(view3); viewPager.setAdapter(pagerAdapter);
viewPager.setOnPageChangeListener(this); btnStart= (Button)viewList.get(2).findViewById(R.id.btnStart);
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { }
});
} public void initDots(){
dots=new ImageView[viewList.size()];
for(int i=0;i<viewList.size();i++){
dots[i]= (ImageView) findViewById(ids[i]);
}
} @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override
public void onPageSelected(int position) { for (int i=0;i<ids.length;i++){
if(position==i){
dots[i].setImageResource(R.drawable.login_point_selected);
}else {
dots[i].setImageResource(R.drawable.login_point);
}
}
} @Override
public void onPageScrollStateChanged(int state) { }
}
Android学习总结——欢迎页和导航页的实现的更多相关文章
- Android学习记录:ViewPager实现欢迎页
许多APP在第一次启动的时候,都会有welcome page.近日尝试利用ViewPager来实现Welcome Page. d0711 完成记录,跟新下载地址 =================== ...
- Android学习笔记- Fragment实例 底部导航栏的实现
1.要实现的效果图以及工程目录结构: 先看看效果图吧: 接着看看我们的工程的目录结构: 2.实现流程: Step 1:写下底部选项的一些资源文件 我们从图上可以看到,我们底部的每一项点击的时候都有不同 ...
- 应用app首次进入导航页动画
import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActi ...
- 用Flutter开发的跨平台项目,完美运行在Android和IOS上,Material简洁风格,包括启动页、引导页、注册、登录、首页、体系、公众号、导航、项目,还有漂亮的妹子图库,运行极度流畅,结构清晰,代码规范,值得拥有
Flutter学习资源汇总持续更新中...... Flutter官方网站 Flutter中文网 wendux的Flutter实战 Flutter官方exampleflutter_gallery 阿里巴 ...
- Android学习笔记之滑动翻页(屏幕切换)
如何实现手机上手动滑动翻页效果呢?呵呵,在这里我们就给你们介绍一下吧. 一般实现这个特效会用到一个控件:ViewFlipper <1>View切换的控件—ViewFlipper 这个控件是 ...
- Android学习笔记_37_ListView批量加载数据和页脚设置
1.在activity_main.xml布局文件中加入ListView控件: <RelativeLayout xmlns:android="http://schemas.android ...
- 导航页的开发--手机web app开发笔记
好了,的所有的基础知识已经准备完毕了,现在开始制作引导页.这个引导页需要一个HTML文件,JS文件,一个CSS文件.在HBuilderX中根目录下添加“Guid.html”,在JS文件夹添加“myth ...
- android_ViewPager_实现导航页
android_ViewPager_实现导航页 既然是实现导航页的效果,那么我们肯定是要实现ViewPager的 要实现的效果如下 1.用户进入欢迎页面 2.判断是否是第一次进入,如果是,则进入导航页 ...
- noteless的博客导航页 所有文章的导航页面
导航 <spring springmvc mybatis maven 项目整合示例系列-导航页> <JAVA 基础知识点拾遗系列 JAVA学习 -1层 导航页> <计 ...
随机推荐
- 如何将XML转换成XSD(XML Schema)文件
将xml装换为xsd,先决条件是已经安装了Visual Stutio 1) 输入cmd在运行窗口 2) 将xsd的路径加入到path变量 set path=%path%;C:\Program File ...
- 自写图片遮罩层放大功能jquery插件源代码,photobox.js 1.0版,不兼容IE6
阿嚏~~~ 话说本屌丝没啥开发插件的经验,可是天公不作美,公司须要让我自己开发个图片放大的插件 但公司老大的话,宛如吾皇之圣旨,微臣必当肝脑涂地,莫敢不从啊~~~ 于是乎,作为一个超级小白,本人仅仅能 ...
- [置顶] 【VB.NET2010】注册表写入方法
这里,以添加启动项为例: Imports Microsoft.Win32 Imports System.Reflection.Assembly Private Sub SetAuto_Click( ...
- CentOS7--Xshell网络中断引起的vi编辑文件问题
在编写Python的程序时,由于不小心触碰网线使xshell出现网络中断问题,当再次以vi命令打开文件准备编辑时,发现爆出英文错误: 该错误的英文翻译大概是(1)另一个程序也在编译这个文件,如果是这样 ...
- shell常用命令的用法
1. 如何把 /etc/passwd 中用户uid 大于500 的行给打印出来?awk -F ':' '$3>500' /etc/passwd 2. awk中 NR,NF两个变量表示什么含义?N ...
- Win7访问局域网内共享文件夹
\\192.168.1.102\\IP地址
- contenteditable 属性
定义和用法 contenteditable 属性规定是否可编辑元素的内容. 语法 <element contenteditable="value"> 属性值 值 描述 ...
- js获取上传文件扩展名
File_box.value.substring(File_box.value.lastIndexOf(".") + 1);
- Windows命令行(DOS命令)教程-3(转载)http://arch.pconline.com.cn//pcedu/rookie/basic/10111/15325_2.html
五.常用命令 DOS命令总共大约有一百个(包括文本编辑.查杀病毒.配置文件.批处理等),我们这里详细介绍二十个常用的DOS命令. 先介绍一下通配符的概念. 通配符*和? *表示一个字符串 ?只代表一个 ...
- MySql安装与卸载
win2003下MySql的配置 准备相关组件 1.MySql安装包 mysql-installer-commercial- 5.6.14.0.msi 2.Microsoft .NETFramewor ...