package com.photo;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class PhotoAlbum extends Activity {
/** Called when the activity is first created. */
private Spinner mSpinner;
private ImageView mImageView1,mImageView2,mImageView3,mImageView4,mImageView5,mImageView6;
private ImageButton mImageButton_help,mImageButton_close;
private ImageButton mImageButton_pre,mImageButton_next;
private ImageButton mImageButton_take_photo,mImageButton_synchro_photo;
private TextView mTextView_photo_num;
private int H,m,s; //定义时、分、秒
private Calendar c;
private TextView mTextView_hour,mTextView_minute;
private static final String PATH = "/sdcard/photo/";
private String[] photo_folder;
private ArrayAdapter<String> adapter;
private String folder_name;
private List<List<String>> listParent = new ArrayList<List<String>>();
private List<String> listChild = new ArrayList<String>();
private ImageView[] imageViews;
private int list_id = 0;
private int size; //某一文件夹下所有图片的数量
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setScreen();
setContentView(R.layout.main);
//初始化UI对象
findViews();
//事件监听
setOnListener();
//获取当前时间
getCurrentTime();
//定时器
handler.postDelayed(task, 1000);
listPhotoFolder(PATH);
}
public void setScreen(){
//设置全屏窗口
requestWindowFeature(Window.FEATURE_NO_TITLE);
//全屏
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
//横屏显示
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
public void findViews(){
//显示系统时间
mTextView_hour = (TextView) findViewById(R.id.TextView_hour);
mTextView_minute = (TextView) findViewById(R.id.TextView_minute);
mSpinner = (Spinner) findViewById(R.id.Spinner);
mImageView1 = (ImageView) findViewById(R.id.ImageView1);
mImageView2 = (ImageView) findViewById(R.id.ImageView2);
mImageView3 = (ImageView) findViewById(R.id.ImageView3);
mImageView4 = (ImageView) findViewById(R.id.ImageView4);
mImageView5 = (ImageView) findViewById(R.id.ImageView5);
mImageView6 = (ImageView) findViewById(R.id.ImageView6);
imageViews = new ImageView[]{mImageView1,mImageView2,mImageView3,mImageView4,mImageView5,mImageView6};
mImageButton_help = (ImageButton) findViewById(R.id.ImageButton_help);
mImageButton_close = (ImageButton) findViewById(R.id.ImageButton_close);
mImageButton_pre = (ImageButton) findViewById(R.id.ImageButton_pre);
mImageButton_next = (ImageButton) findViewById(R.id.ImageButton_next);
mImageButton_take_photo = (ImageButton) findViewById(R.id.ImageButton_take_photo);
mImageButton_synchro_photo = (ImageButton) findViewById(R.id.ImageButton_synchro_photo);
mImageButton_pre.setVisibility(View.INVISIBLE);
mImageButton_next.setVisibility(View.INVISIBLE);
for(int i = 0;i < 6;i ++){
imageViews[i].setVisibility(View.GONE);
imageViews[i].setEnabled(false);
}
mImageButton_help.setBackgroundDrawable(getResources().getDrawable(R.drawable.help));
mImageButton_close.setBackgroundDrawable(getResources().getDrawable(R.drawable.close));
mImageButton_pre.setBackgroundDrawable(getResources().getDrawable(R.drawable.pre_nor));
mImageButton_next.setBackgroundDrawable(getResources().getDrawable(R.drawable.next_nor));
mImageButton_take_photo.setBackgroundDrawable(getResources().getDrawable(R.drawable.take_photo_normal));
mImageButton_synchro_photo.setBackgroundDrawable(getResources().getDrawable(R.drawable.synchro_photo_normal));
mTextView_photo_num = (TextView) findViewById(R.id.TextView_photo_num);
}
//获取当前时间
public void getCurrentTime(){
c = Calendar.getInstance();
H = c.get(Calendar.HOUR_OF_DAY);
m = c.get(Calendar.MINUTE);
s = c.get(Calendar.SECOND);
mTextView_hour.setText(format(H));
mTextView_minute.setText(format(m));
}
//用定时器来显示时间
private Handler handler = new Handler();
private Runnable task = new Runnable(){
public void run() {
handler.postDelayed(task, 1000);
if(s < 60){
s ++;
}else if(m < 60){
s = 0;
m++;
}else if(H < 24){
m = 0;
H++;
}else{
H = 0;
}
mTextView_hour.setText(format(H));
mTextView_minute.setText(format(m));
}
};
//事件监听
public void setOnListener(){
mSpinner.setOnItemSelectedListener(spinner);
mImageButton_help.setOnClickListener(btn_help);
mImageButton_close.setOnClickListener(btn_close);
mImageButton_pre.setOnClickListener(btn_pre);
mImageButton_next.setOnClickListener(btn_next);
for(int i = 0;i < 6;i ++){
final int n = i;
imageViews[n].setOnClickListener(new ImageView.OnClickListener(){
public void onClick(View v) {
mMakeText(list_id + "--" + n,true);
Intent intent = new Intent();
intent.setClass(PhotoAlbum.this,ShowPhoto.class);
Bundle bundle = new Bundle();
bundle.putInt("list_id", list_id);
bundle.putInt("photo_id", n);
bundle.putString("folder_name", folder_name);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}
//帮助按钮
ImageButton.OnClickListener btn_help = new ImageButton.OnClickListener(){
public void onClick(View v) {
Toast.makeText(PhotoAlbum.this, "此功能还没完善,谢谢使用!", Toast.LENGTH_SHORT).show();
}
};
//关闭按钮
ImageButton.OnClickListener btn_close = new ImageButton.OnClickListener(){
public void onClick(View v) {
Dialog dialog = new AlertDialog.Builder(PhotoAlbum.this)
.setTitle("退出提示!")
.setMessage("您确定要退出吗?")
.setPositiveButton("确定",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
PhotoAlbum.this.finish();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create();
dialog.show();
}
};
//下拉列表事件,选择文件夹,显示该文件夹下的所有图片,默认显示第一个文件夹的相片
Spinner.OnItemSelectedListener spinner = new Spinner.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
folder_name = photo_folder[arg2];
list_id = 0;
listParent.clear(); //重新选择时将父列表和子列表都清空
listChild.clear();
mImageButton_pre.setVisibility(View.VISIBLE);
mImageButton_next.setVisibility(View.VISIBLE);
listPhoto(folder_name);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
};
//上一个图片
ImageButton.OnClickListener btn_pre = new ImageButton.OnClickListener(){
public void onClick(View v) {
list_id --;
showPhotos(folder_name,listParent.get(list_id));
judge();
}
};
//下一个图片
ImageButton.OnClickListener btn_next = new ImageButton.OnClickListener(){
public void onClick(View v) {
list_id ++;
showPhotos(folder_name,listParent.get(list_id));
judge();
}
};
//遍历photo文件夹下的所有文件夹
public v
没有合适的资源?快使用搜索试试~ 我知道了~
Android 多媒体—相册
共58个文件
class:28个
png:17个
xml:4个
3星 · 超过75%的资源 需积分: 3 86 下载量 99 浏览量
2010-11-09
09:07:01
上传
评论 3
收藏 1.33MB ZIP 举报
温馨提示
在Android上做的一个相册的功能,选不同的文件夹显示该文件夹的所以图片,图片分页显示
资源推荐
资源详情
资源评论
收起资源包目录
PhotoAlbum.zip (58个子文件)
PhotoAlbum
.project 846B
default.properties 364B
bin
com
photo
PhotoAlbum.class 11KB
R$string.class 400B
ShowPhoto$2.class 2KB
R$layout.class 401B
ShowPhoto$5$2.class 797B
ShowPhoto$1.class 868B
PhotoAlbum$3.class 2KB
R$drawable.class 841B
PhotoAlbum$4.class 2KB
PhotoAlbum$2.class 874B
ShowPhoto$4.class 855B
ShowPhoto$2$1.class 925B
ShowPhoto$2$2.class 797B
PhotoAlbum$5.class 1KB
R.class 468B
ShowPhoto$3.class 855B
PhotoAlbum$6.class 1KB
ShowPhoto$6.class 665B
ShowPhoto$5$1.class 2KB
ShowPhoto$7.class 695B
ShowPhoto.class 8KB
ShowPhoto$5.class 2KB
PhotoAlbum$1.class 1KB
R$attr.class 313B
PhotoAlbum$3$2.class 803B
PhotoAlbum$7.class 2KB
R$id.class 1KB
PhotoAlbum$3$1.class 934B
resources.ap_ 419KB
PhotoAlbum.apk 432KB
classes.dex 23KB
AndroidManifest.xml 820B
src
com
photo
ShowPhoto.java 9KB
PhotoAlbum.java 12KB
res
values
strings.xml 168B
layout
show_photo.xml 2KB
main.xml 3KB
drawable-ldpi
icon.png 2KB
drawable-hdpi
play_nor.png 3KB
close.png 2KB
take_photo_normal.png 2KB
back_nor.png 2KB
pre_dis.png 2KB
next_nor.png 5KB
help.png 2KB
bg_photo2.png 169KB
next_dis.png 3KB
bg_photo1.png 110KB
bg_make_plan.png 164KB
synchro_photo_normal.png 2KB
pre_nor.png 4KB
delete_nor.png 2KB
icon.png 4KB
drawable-mdpi
icon.png 3KB
.classpath 280B
gen
com
photo
R.java 3KB
assets
共 58 条
- 1
鄙人姓胡
- 粉丝: 42
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页