android图片浏览器 代码

有没有哪位高手能够提供一个Android的图片管理软件的代码昂!急需!!!!!... 有没有哪位高手能够提供一个Android的图片管理软件的代码昂!急需!!!!! 展开
 我来答
匿名用户
推荐于2016-09-07
展开全部
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package android.apps;import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;public class Gallery1 extends Activity {
private Context mContext;
private Uri[] uri =GetImagesFromSDCard.uriArray;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//影藏顶部程序名称 写在setContentView(R.layout.gallery_1);之前,不然报错
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.gallery_1);
//影藏顶部电量等图标
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter(this));
//设置显示第几张图片 参数是GetImagesFromSDCard中的静态变量
g.setSelection(GetImagesFromSDCard.imagePosition);
}

public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
public ImageAdapter(Context c) {
mContext = c;
/*
* 使用在res/values/attrs.xml中的<declare-styleable>定义 的Gallery属性.
*/
TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
/* 取得Gallery属性的Index id */
mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground, 0);
/* 让对象的styleable属性能够反复使用 */
a.recycle();
} /* 重写的方法getCount,返回图片数目 */
public int getCount() {
return uri.length;
} /* 重写的方法getItemId,返回图像的数组id */ public Object getItem(int position) {
return position;
} public long getItemId(int position) {
return position;
} /* 重写的方法getView,返回一View对象 */
public View getView(int position, View convertView, ViewGroup parent){
ImageView view = new ImageView(Gallery1.this);
//设置所有图片的资源地址
view.setImageURI(uri[position]);
view.setScaleType(ImageView.ScaleType.FIT_XY);
view.setLayoutParams(new Gallery.LayoutParams(240, 320));
/* 设置Gallery背景图 */
view.setBackgroundResource(mGalleryItemBackground);
return view;
}

}
}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式