文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > ImageSwitcher的相册
侵权投诉

ImageSwitcher的相册

ImageSwitcher配合Gallery读取手机相册

public class mainactivity extends Activity implements

OnItemSelectedListener, ViewFactory {

private ImageSwitcher is;

private Gallery gallery;



private Integer[] mThumbIds = { R.drawable.b, R.drawable.c,

R.drawable.d, R.drawable.f, R.drawable.g,

};



private Integer[] mImageIds = { R.drawable.b, R.drawable.c,

R.drawable.d, R.drawable.f, R.drawable.g, };



@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);



is = (ImageSwitcher) findViewById(R.id.switcher);

is.setFactory(this);



is.setInAnimation(AnimationUtils.loadAnimation(this,

android.R.anim.fade_in));

is.setOutAnimation(AnimationUtils.loadAnimation(this,

android.R.anim.fade_out));



gallery = (Gallery) findViewById(R.id.gallery);



gallery.setAdapter(new ImageAdapter(this));

gallery.setOnItemSelectedListener(this);

}



@Override

public View makeView() {

ImageView i = new ImageView(this);

i.setBackgroundColor(0xFF000000);

i.setScaleType(ImageView.ScaleType.FIT_CENTER);

i.setLayoutParams(new ImageSwitcher.LayoutParams(

LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

return i;

}



public class ImageAdapter extends BaseAdapter {

public ImageAdapter(Context c) {

mContext = c;

}



public int getCount() {

return mThumbIds.length;

}



public Object getItem(int position) {

return position;

}



public long getItemId(int position) {

return position;

}



public View getView(int position, View convertView, ViewGroup parent) {

ImageView i = new ImageView(mContext);



i.setImageResource(mThumbIds[position]);

i.setAdjustViewBounds(true);

i.setLayoutParams(new Gallery.LayoutParams(

LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

i.setBackgroundResource(R.drawable.e);

return i;

}



private Context mContext;



}



@Override

public void onItemSelected(AdapterView<?> parent, View view, int position,

long id) {

is.setImageResource(mImageIds[position]);



}



@Override

public void onNothingSelected(AdapterView<?> parent) {

}

}

xml文件

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="doc.guandang.net;

android:layout_width="match_parent"

android:layout_height="match_parent">



<ImageSwitcher android:id="@+id/switcher"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_alignParentTop="true"

android:layout_alignParentLeft="true"

/>



<Gallery android:id="@+id/gallery"

android:background

第1页

你可能喜欢

热门文档

相关文档

  • 切换图片ImageSwitcher

    ImageSwitcher 类必须设置一个 ViewFactory,主要用来将显示的图片和父窗口区分开来,因此需要实现 ViewSwitcher.ViewFactory 接口,通过 makeView()方法来显示图片,这里会返...

  • Android-ImageSwitcher图片切换

    Android-ImageSwitcher图片切换_计算机软件及应用_IT/计算机_专业资料。Android-ImageSwitcher图片切换AVD SDK Activity_main.xml <LinearLayout xmlns:android="http:/...

  • Android 控件ImageSwitcher

    Android 控件ImageSwitcher_IT/计算机_专业资料。Android 控件ImageSwitcherImageSwitcher 是 Android 中控制图片展示效果的一个控件,效果图如下: 一、重要方法 ...

  • Android-Gallery和ImageSwitcher结合完成图片拖动和切换

    Android-Gallery和ImageSwitcher结合完成图片拖动和切换_计算机软件及应用_IT/计算机_专业资料。Android-Gallery和ImageSwitcher结合完成图片拖动和切换.doc...

  • Android 之Gallery及ImageSwitcher组件

    由麦可网整理,转载请注明出处 Android 之 Gallery 及 ImageSwitcher 组件 Gallery 组件一般用于显示图像列表,因此也可称相册组件 Gallery 与 GridView 的区别是 ...

  • 相册

    相册(ImageSwitcher&Gallery) 第一步:布局文件main.xml中加入ImageSwitcher和Gallery 控件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:...

  • Android图片相框

    } return newbmp; = (ImageSwitcher)findViewById(R.id.switcher01); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, ...

  • Android ImageSwitcher学习笔记(An-Beer工作室)

    Android ImageSwitcher 学习笔记 ImageSwitcher 是 Android 中控制图片展示效果的一个控件,如:幻灯片效果...,颇有感觉啊。 做相册一绝 源码下载 一、重要方法 ...

  • Android 之Gallery及ImageSwitcher组件

    Android 之Gallery及ImageSwitcher组件 Gallery 组件一般用于显示图像列表,因此也可称相册组件 Gallery 与GridView 的区别是Gallery只能水平显 示一行,而且支持水平...

  • Android图片浏览源码解读

    (ImageSwitcher) findViewById(R.id.switcher); 33 mSwitcher.setFactory(this); 34 mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, 35 Android.R.anim...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email