package org.ourunix.android.gallerytest;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
public class GalleryTestActivity extends Activity {
private Context mContext;
private Gallery myGallery;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setView();
}
public void setView(){
mContext = this;
myGallery = (Gallery) findViewById(R.id.mygallery);
myGallery.setAdapter(new ImagAdapter());
}
public class ImagAdapter extends BaseAdapter{
private Integer[] imgRes = {
R.drawable.p1,
R.drawable.p2,
R.drawable.p3
};
public ImagAdapter(){
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return imgRes.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return imgRes[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView img;
if (convertView == null){
img = new ImageView(mContext);
convertView = img;
convertView.setTag(img);
}else {
img = (ImageView) convertView.getTag();
}
img.setImageResource(imgRes[position]);
img.setLayoutParams(new Gallery.LayoutParams(200, 200));
img.setScaleType(ImageView.ScaleType.FIT_XY);
return convertView;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
GalleryTest.7z (30个子文件)
GalleryTest
bin
classes.dex 4KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
GalleryTest.apk 196KB
classes
org
ourunix
android
gallerytest
R$layout.class 433B
R$id.class 426B
R$drawable.class 524B
R$attr.class 379B
R.class 622B
R$string.class 466B
GalleryTestActivity$ImagAdapter.class 2KB
GalleryTestActivity.class 1KB
resources.ap_ 192KB
GalleryTestActivity.apk 196KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
p3.jpg 87KB
ic_launcher.png 4KB
p2.jpg 6KB
p1.jpg 88KB
values
strings.xml 188B
drawable-mdpi
ic_launcher.png 3KB
layout
main.xml 541B
assets
gen
org
ourunix
android
gallerytest
R.java 902B
proguard.cfg 1KB
src
org
ourunix
android
gallerytest
GalleryTestActivity.java 2KB
.project 847B
.classpath 364B
project.properties 360B
AndroidManifest.xml 756B
共 30 条
- 1
Lorinnn
- 粉丝: 37
- 资源: 47
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页