package com.demo.activity;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.widget.Gallery;
/**
*
* @author cl
*
*/
public class MainActivity extends Activity {
private Gallery gallery;
private FocusAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery=(Gallery)findViewById(R.id.gallery);
adapter=new FocusAdapter(this);
Map<String,Object> map1=new HashMap<String,Object>();
map1.put("focusImage",R.drawable.focus_1);
map1.put("intro", "这是内容简介1这是内容简介1这是内容简介1这是内容简介1这是内容简介1这是内容简介1");
Map<String,Object> map2=new HashMap<String,Object>();
map2.put("focusImage",R.drawable.focus_2);
map2.put("intro", "这是内容简介2这是内容简介2这是内容简介2这是内容简介2这是内容简介2这是内容简介2");
Map<String,Object> map3=new HashMap<String,Object>();
map3.put("focusImage",R.drawable.focus_3);
map3.put("intro", "这是内容简介3这是内容简介3这是内容简介3这是内容简介3这是内容简介3这是内容简介3");
Map<String,Object> map4=new HashMap<String,Object>();
map4.put("focusImage",R.drawable.focus_4);
map4.put("intro", "这是内容简介4这是内容简介4这是内容简介4这是内容简介4这是内容简介4这是内容简介4");
Map<String,Object> map5=new HashMap<String,Object>();
map5.put("focusImage",R.drawable.focus_5);
map5.put("intro", "这是内容简介5这是内容简介5这是内容简介5这是内容简介5这是内容简介5这是内容简介5");
adapter.addFocus(map1);
adapter.addFocus(map2);
adapter.addFocus(map3);
adapter.addFocus(map4);
adapter.addFocus(map5);
gallery.setAdapter(adapter);
final int count = 5;//滚动图片的总数
final Handler autoGalleryHandler = new Handler() {
public void handleMessage(Message message) {
super.handleMessage(message);
switch (message.what) {
case 1:
gallery.setSelection(message.getData().getInt("pos"));
break;
}
}
};
Timer autoGallery = new Timer();
autoGallery.schedule(new TimerTask() {
int gallerypisition = 0;
@Override
public void run() {
if (gallerypisition < count - 1) {
gallerypisition = gallerypisition + 1;
} else {
gallerypisition = 0;
}
Message msg = new Message();
Bundle date = new Bundle();// 存放数据
date.putInt("pos", gallerypisition);
msg.setData(date);
msg.what = 1;//消息标识
autoGalleryHandler.sendMessage(msg);
}
}, 5000, 5000);//5秒后,每隔5秒执行信息发送
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
demo_focus.rar (59个子文件)
demo_focus
.project 846B
project.properties 360B
proguard.cfg 1KB
src
com
demo
activity
FocusAdapter.java 2KB
MainActivity.java 3KB
AndroidManifest.xml 739B
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
focus_point_5.png 3KB
focus_3.jpg 79KB
icon.png 4KB
focus_1.jpg 139KB
focus_point_4.png 3KB
focus_5.jpg 71KB
focus_2.jpg 76KB
focus_bg.png 3KB
focus_point_3.png 3KB
focus_point_1.png 3KB
focus_point_2.png 3KB
focus_4.jpg 40KB
drawable-mdpi
icon.png 3KB
layout
focus.xml 892B
main.xml 387B
values
color.xml 104B
strings.xml 172B
assets
gen
com
demo
activity
R.java 2KB
default.properties 362B
.classpath 288B
bin
demo_focus.apk 427KB
resources.ap_ 421KB
classes
com
demo
activity
R$layout.class 420B
R$drawable.class 769B
R$attr.class 337B
FocusAdapter.class 3KB
R$id.class 501B
MainActivity$2.class 1KB
R.class 571B
R$string.class 424B
MainActivity$1.class 1KB
MainActivity.class 3KB
R$color.class 389B
com
demo
activity
R$layout.class 420B
R$drawable.class 769B
R$attr.class 337B
FocusAdapter.class 3KB
R$id.class 501B
R.class 571B
R$string.class 424B
MainActivity.class 2KB
R$color.class 389B
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
focus_point_5.png 296B
icon.png 4KB
focus_point_4.png 297B
focus_bg.png 110B
focus_point_3.png 297B
focus_point_1.png 296B
focus_point_2.png 308B
drawable-mdpi
icon.png 2KB
classes.dex 8KB
共 59 条
- 1
clwxx628530
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 实验项目一:线性表(模板 ).docx
- 基于LM317A设计交流220V输入可调5V-12V直流输出稳压电源电路multisim10仿真源文件.zip
- Screenshot_2024-04-25-17-04-18-55_2332cb9b27b851b548ba47a91682926c.jpg
- -基于AVR单片机的LNG加液机控制器设计.pdf
- ThePowerOfNow-EckhartTolle.mobi
- BLOCK_TYPE_HEARTBEAT_D70A3465D4EE4E9_046141_dump_1st.dmp
- 项目方法测试调用接口工具
- studyupdate
- 基于西瓜数据集的决策树实现.zip
- 60套HTML网站源码-响应式-涵盖(简历&作品展示&商业&科技&培训&商城&课设等)-适配移动设备-解压即用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页