注意:课程设计只为完成任务,不做细节描述~

滑动界面

 package com.example.myapplication;

 import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import Utils.AboutVersion; public class MainActivity extends AppCompatActivity {
private Handler handle=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//得到Handler的对象,默认接收消息
handle = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
int a=msg.what;
AboutVersion aboutAboutVersion = new AboutVersion();
int ver= aboutAboutVersion.getSaveVersion(MainActivity.this);
int saveServison= aboutAboutVersion.getSaveVersion(MainActivity.this);
if(ver==saveServison){
//没有更新 跳转到主界面
Intent intent = new Intent(MainActivity.this,HomeActivity.class);
startActivity(intent);
}else{
aboutAboutVersion.saveVersion(MainActivity.this);
Intent intent=new Intent(MainActivity.this,WelcomeActivity.class);
//貌似获取版本失败了
startActivity(intent);
}
}
};
new FirstThread().start();
}
class FirstThread extends Thread{
@Override
public void run() {
super.run();
try {
Thread.sleep(1000);
handle.sendEmptyMessage(11);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
 
package com.example.myapplication;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button; public class HomeActivity extends AppCompatActivity {
private Button btn_first,btn_theme,btn_person;
private FirstFragment first;
private ThemFragment ThemFragment;
private PersonFragment PersonFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
initView();
//开启碎片管理器
FragmentManager manager =getFragmentManager();
//开启碎片事物
FragmentTransaction action =manager.beginTransaction();
first = new FirstFragment();
//将fragment的对象添加到帧布局中
action.add(R.id.frame,first);
action.commit();
}
public void initView(){
btn_first= (Button) findViewById(R.id.firstPage);
btn_theme= (Button) findViewById(R.id.mainTheme);
btn_person=(Button) findViewById(R.id.My);
btn_first.setSelected(true);
btn_person.setSelected(false);
btn_theme.setSelected(false);
}
/*
该方法是由布局文件的Onclick属性指定过来的,修饰符需要pubilc,方法名需要和Onclick的值相同
*/ public void Click(View v){
btn_first.setSelected(false);
btn_person.setSelected(false);
btn_theme.setSelected(false);
FragmentManager mananger = getFragmentManager();
FragmentTransaction action=mananger.beginTransaction();
switch (v.getId()){
case R.id.firstPage:
btn_first.setSelected(true);
if(first==null){
first= new FirstFragment();
}
action.replace(R.id.frame,first);
action.commit();
break;
case R.id.mainTheme:
btn_theme.setSelected(true);
if(ThemFragment ==null){
ThemFragment =new ThemFragment();
}
action.replace(R.id.frame, ThemFragment);
action.commit();
break;
case R.id.My:
btn_person.setSelected(true);
if(PersonFragment ==null){
PersonFragment =new PersonFragment();
}
action.replace(R.id.frame, PersonFragment);
action.commit();
break;
}
} }
package com.example.myapplication;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; /**
* Created by 樱花落舞 on 2017/6/15.
*/ public class PersonFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_person,container,false);
return view;
}
}
package com.example.myapplication;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; /**
* Created by 樱花落舞 on 2017/6/15.
*/ public class ThemFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_them,container,false);
return view;
}
}
package com.example.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView; import Adapter.WeclomeAdapter; /**
* Created by 樱花落舞 on 2017/6/13.
* 1.创建java文件继承Activity或者activity子类
* 2.重写OnCreate()方法
* 3.添加布局文件
* 4.在清单文件中进行注册
*/ public class WelcomeActivity extends Activity {
private ViewPager pager;
private int images[]={R.mipmap.b,R.mipmap.c,R.mipmap.a};
private ImageView views[]=new ImageView[3];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
pager= (ViewPager) findViewById(R.id.viewapger);
for(int i=0;i<3;i++){
ImageView view=new ImageView(WelcomeActivity.this);
view.setImageResource(images[i]);
views[i]=view;
}
WeclomeAdapter adapter= new WeclomeAdapter(views);
pager.setAdapter(adapter);
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:color="#ffff0000"/> <item android:color="#0fffff" android:state_selected="false"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@mipmap/ico_screen" /> <item android:drawable="@mipmap/ico_screen_pred" android:state_selected="false"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@mipmap/ico_personal_pred"/>
<item android:drawable="@mipmap/ico_personal" android:state_selected="false"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.myapplication.HomeActivity"> <LinearLayout
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:background="#0ccfff"
>
<Button
android:id="@+id/firstPage"
android:drawableTop="@drawable/picture"
android:text="首页"
style="@style/bottomStyle"
android:textColor="@color/barcolor"
android:onClick="Click"
/>
<Button
android:id="@+id/mainTheme"
style="@style/bottomStyle"
android:drawableTop="@drawable/picture2"
android:text="专题"
android:textColor="@color/barcolor"
android:onClick="Click"
/>
<Button
android:id="@+id/My"
style="@style/bottomStyle"
android:drawableTop="@drawable/picture3"
android:text="我的"
android:textColor="@color/barcolor"
android:onClick="Click"
/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frame"
android:layout_above="@id/bottomBar"
></FrameLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.myapplication.MainActivity"
android:background="@mipmap/xiaomai"> </RelativeLayout>
<?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.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewapger"> </android.support.v4.view.ViewPager>
</RelativeLayout>
<?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="#075f3a">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list"
></ListView>
</RelativeLayout>
<?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="#8b844c"> </RelativeLayout>
<?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="#4c648b"> </RelativeLayout>
<resources>

    <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="bottomStyle">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@null</item>
<item name="android:color">@color/barcolor</item>
<item name="android:textSize">12sp</item>
<item name="android:paddingTop">8dp</item>
</style>
</resources>

Android课程设计第五天欢迎界面(滑动)和图形选择的更多相关文章

  1. Android课程设计第六天欢迎界面(跳转)

    注意:课程设计只为完成任务,不做细节描述~ package com.example.myapplication; import android.app.Activity; import android ...

  2. Android课程设计第二天界面排版

    注意:课程设计只为完成任务,不做细节描述~ 老师叫我们做一个这个样子,然后.. <?xml version="1.0" encoding="utf-8"? ...

  3. Android课程设计——博学谷1.0

    本文讲述了如何应用大三下学期智能移动终端开发技术课程所学知识,完成包含服务器端.客户端程序的应用——博学谷登录模块的开发,结合java语言基本知识,例如:字符串.列表.类.数据库读写等,设计.实现一个 ...

  4. Android课程设计第四天ListView运用

    注意:课程设计只为完成任务,不做细节描述~ 效果图 <?xml version="1.0" encoding="utf-8"?> <Relat ...

  5. Android课程设计第三天帧动画区间动画

    注意:课程设计只为完成任务,不做细节描述~ 点火是帧动画,发射是区间动画,于是 <?xml version="1.0" encoding="utf-8"? ...

  6. Android课程设计第一天Android Studio安装

    注意:课程设计只为完成任务,不做细节描述~ 学校有一个Android的课设,所以顺便把Android Studio安装了上去. 实际上安装过程并不复杂,只有几个地方需要注意~ 安装包可以去http:/ ...

  7. python课程设计笔记(五) ----Resuests+BeautifulSoup (爬虫入门)

    官方参考文档(中文版): requests:http://docs.python-requests.org/zh_CN/latest/user/quickstart.html beautifulsou ...

  8. 【Android UI设计与开发】9:滑动菜单栏(一)开源项目SlidingMenu的使用和示例

    一.SlidingMenu简介 相信大家对SlidingMenu都不陌生了,它是一种比较新的设置界面或配置界面的效果,在主界面左滑或者右滑出现设置界面效果,能方便的进行各种操作.很多优秀的应用都采用了 ...

  9. 【Android UI设计与开发】10:滑动菜单栏(二)SlidingMenu 动画效果的实现

    其实就是在显示菜单栏时,有个动画的效果.代码比较简单,下面进行说明. 1.效果图如下,手机上查看效果更佳 2.代码实现,这里只讲解动画效果的实现,具体代码可在源代码中查看 <1> 先定义一 ...

随机推荐

  1. 使用mysql导入数据时关掉binlog

    在my.cnf中注释掉 log-bin=bin-log参数然后重启数据库

  2. AppFuse 3的乱码问题

    书接上回:AppFuse 3常见问题与解决方法,一个新问题:乱码! 在3.0.0版本号下,运行mvn appfuse:full-source命令后使用mvn jetty:run启动工程,页面上就出现了 ...

  3. Codeforces 8VC Venture Cup 2016 - Elimination Round F. Group Projects 差分DP*****

    F. Group Projects   There are n students in a class working on group projects. The students will div ...

  4. SpringInAction4笔记——web

    1,java配置 extends AbstractAnnotationConfigDispatcherServletInitializer public class SpitterWebInitial ...

  5. RubyMine安装、破解

    经常安装东西,这是我安装过最快的ide破解版. 下载地址: http://www.jetbrains.com/ruby/download/index.html 破解序列号: name: rubymin ...

  6. VS1053 datasheet 解读笔记

    pdf  10 pdf 11 ` 左右声道 负载,注意这里的负载指LEFT 到GBUF,RIGHT到GBUF.所以后面会有说明GBUF一定不能连接到GND. pdf 14 pdf 14 从上面的引脚定 ...

  7. C# 软件实现远程桌面调用

    1.https://www.codeproject.com/Articles/19836/Palantir-Remote-Desktop-Manager codeproject项目 2.http:// ...

  8. spring cloud - config 属性自动刷新

    启动config-server,启动成功后就不需要在管了; 在config-client做些修改: 在使用的controller或service的类上加上一个注解@RefreshScope 在pom中 ...

  9. 一个基本的spring+mybatis所需要的包

    spring+mybatis需要的包:org.springframework.spring-webmvc(spring框架DispatcherServlet需要,spring-webmvc会依赖spr ...

  10. java反射机制与动态加载类

    什么是java反射机制? 1.当程序运行时,允许改变程序结构或变量类型,这种语言称为动态语言.我们认为java并不是动态语言,但是它却有一个非常突出的动态相关机制,俗称:反射. IT行业里这么说,没有 ...