package com.drocode.swithcer;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import android.text.Spanned;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
public class ImageAdapter extends BaseAdapter{
private List<String> imageUrls; //图片地址list
private Context context;
private ImageAdapter self;
Uri uri;
Intent intent;
ImageView imageView;
public static Integer[] imgs = {
R.drawable.one,
R.drawable.two,
R.drawable.three,
R.drawable.four
};
private String[] myuri = {
"http://www.36939.net/",
"http://www.36939.net/",
"http://www.36939.net/",
"http://www.36939.net/"
};
public ImageAdapter(/*List<String> imageUrls, */Context context) {
// this.imageUrls = imageUrls;
this.context = context;
this.self = this;
}
public int getCount() {
return Integer.MAX_VALUE;
}
public Object getItem(int position) {
return imageUrls.get(position % imgs.length);
}
public long getItemId(int position) {
return position;
}
@SuppressWarnings("unused")
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
try {
switch (msg.what) {
case 0: {
self.notifyDataSetChanged();
}
break;
}
super.handleMessage(msg);
} catch (Exception e) {
}
}
};
public View getView(int position, View convertView, ViewGroup parent) {
//Bitmap image;
if(convertView==null){
convertView = LayoutInflater.from(context).inflate(R.layout.item,null); //实例化convertView
Gallery.LayoutParams params = new Gallery.LayoutParams(Gallery.LayoutParams.WRAP_CONTENT,Gallery.LayoutParams.WRAP_CONTENT);
convertView.setLayoutParams(params);
// image = ((ImageActivity)context).imagesCache.get(imageUrls.get(position % imageUrls.size())); //从缓存中读取图片
/* if(image==null){
//当缓存中没有要使用的图片时,先显示默认的图片
image = ((ImageActivity)context).imagesCache.get("background_non_load");
//异步加载图片
LoadImageTask task = new LoadImageTask(convertView);
task.execute(imageUrls.get(position % imageUrls.size()));
} */
convertView.setTag(imgs);
}
else{
//image = (Bitmap) convertView.getTag();
}
// TextView textView = (TextView) convertView.findViewById(R.id.gallery_text);
// textView.setText(position % imgs.length+" sdfsdfdsfdf");
// textView.setBackgroundColor(Color.argb(200, 135, 135, 152));
imageView = (ImageView) convertView.findViewById(R.id.gallery_image);
imageView.setImageResource(imgs[position % imgs.length]);
//设置缩放比例:保持原样
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
// textView.setText(position % imgs.length+" sdfsdfdsfdf");
((ImageActivity)context).changePointView(position % imgs.length);
/* imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//((String) imageView).setSpan(new URLSpan("http://www.36939.net/"), 13, 15,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
});*/
return convertView;
}
/* //加载图片的异步任务
class LoadImageTask extends AsyncTask<String,Void,Bitmap>{
private View resultView;
LoadImageTask(View resultView) {
this.resultView = resultView;
}
// doInBackground完成后才会被调用
@Override
protected void onPostExecute(Bitmap bitmap) {
//调用setTag保存图片以便于自动更新图片
resultView.setTag(bitmap);
}
//从网上下载图片
@Override
protected Bitmap doInBackground(String... params) {
Bitmap image=null;
try {
//new URL对象 把网址传入
URL url = new URL(params[0]);
//取得链接
URLConnection conn = url.openConnection();
conn.connect();
//取得返回的InputStream
InputStream is = conn.getInputStream();
//将InputStream变为Bitmap
image = BitmapFactory.decodeStream(is);
is.close();
((ImageActivity)context).imagesCache.put(params[0],image); //把下载好的图片保存到缓存中
Message m = new Message();
m.what = 0;
mHandler.sendMessage(m);
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
} */
}
没有合适的资源?快使用搜索试试~ 我知道了~
源码 广告轮播效果源码.rar
共65个文件
png:22个
class:17个
xml:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 182 浏览量
2023-03-23
08:51:52
上传
评论
收藏 1.33MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
源码 广告轮播效果源码.rar (65个子文件)
ImageSwither
ImageSwither
project.properties 361B
.classpath 364B
.settings
org.eclipse.jdt.core.prefs 629B
org.eclipse.core.resources.prefs 122B
assets
src
com
drocode
swithcer
GuideGallery.java 2KB
ImageActivity.java 5KB
ImageAdapter.java 6KB
res
anim
push_up_out.xml 280B
push_up_in.xml 279B
drawable-mdpi
icon.png 3KB
drawable-xhdpi
drawable-ldpi
icon.png 2KB
values
strings.xml 170B
layout
item.xml 888B
url_connection_image.xml 1KB
drawable-hdpi
grayicon.png 3KB
Thumbs.db 17KB
loading.gif 5KB
one.png 114KB
feature_point_cur.png 42KB
four.png 65KB
two.png 60KB
feature_point.png 2KB
greenicon.png 3KB
icon.png 4KB
three.png 65KB
bin
classes
com
drocode
swithcer
ImageActivity$1.class 1KB
R$string.class 433B
ImageAdapter$1.class 967B
R$layout.class 444B
ImageActivity$3.class 2KB
GuideGallery$1.class 872B
R$id.class 523B
ImageActivity$ImageTimerTask.class 2KB
ImageActivity$2.class 1KB
BuildConfig.class 349B
R$attr.class 346B
ImageAdapter.class 3KB
R$drawable.class 691B
GuideGallery.class 3KB
ImageActivity.class 4KB
R.class 593B
R$anim.class 435B
resources.ap_ 326KB
jarlist.cache 119B
res
drawable-mdpi
icon.png 2KB
drawable-ldpi
icon.png 2KB
drawable-hdpi
grayicon.png 657B
one.png 114KB
feature_point_cur.png 586B
four.png 65KB
two.png 60KB
feature_point.png 307B
greenicon.png 673B
icon.png 4KB
three.png 64KB
ImageSwither.apk 335KB
classes.dex 15KB
dexedLibs
annotations-95eaf7e1b2129450b428730832c97ec8.jar 943B
AndroidManifest.xml 758B
proguard.cfg 1KB
default.properties 35B
.project 848B
AndroidManifest.xml 758B
gen
com
drocode
swithcer
BuildConfig.java 162B
R.java 2KB
共 65 条
- 1
资源评论
荣华富贵8
- 粉丝: 150
- 资源: 7649
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功