曾经被Iphone用手指在屏幕上滑来滑去拖动图片的操作方式吸引吗?在Android里头,这并不是什么难事。
IaiaiActivity.java类:
package com.iaiai.activity;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
/**
*
* <p>
* Title: IaiaiActivity.java
* </p>
* <p>
* E-Mail: 176291935@qq.com
* </p>
* <p>
* QQ: 176291935
* </p>
* <p>
* Http: iaiai.iteye.com
* </p>
* <p>
* Create time: 2011-6-26
* </p>
*
* @author 丸子
* @version 0.0.1
*/
public class IaiaiActivity extends Activity {
private IaiaiService iaiaiService;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Gallery mGallery = (Gallery) findViewById(R.id.Gallery01);
mGallery.setAdapter(new ImageApdater(this));
}
public class ImageApdater extends BaseAdapter {
// 类成员myContext为context父类
private Context myContext;
private int[] myImageIds = { R.drawable.a, R.drawable.b, R.drawable.c,
R.drawable.d, R.drawable.e };
// 构造函数,有一个参数,即要存储的Context
public ImageApdater(Context c) {
// TODO Auto-generated constructor stub
this.myContext = c;
}
// 返回所有的图片总数量
@Override
public int getCount() {
// TODO Auto-generated method stub
return this.myImageIds.length;
}
// 利用getItem方法,取得目前容器中图像的数组ID
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
// 取得目前欲显示的图像的VIEW,传入数组ID值使之读取与成像
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView i = new ImageView(this.myContext);
i.setImageResource(this.myImageIds[position]);
i.setScaleType(ImageView.ScaleType.FIT_XY);
// i.setLayoutParams(new Gallery.LayoutParams(120,120));
return i;
}
}
}
main.xml布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Gallery android:id="@+id/Gallery01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Gallery>
</LinearLayout>
- 大小: 45.9 KB
分享到:
相关推荐
android 图片拼接 缩放 特效 拖动 翻转
非常不错的海报拖动特效,使程序更加美观。
android gallery画廊 如iPhone拖动相片特效
此Android工程通过在ImageAdapter里加入Gallery,实现了图片拖动效果,并通过ScaleAnimation实现了点击某个图片使其放大的功能。
android viewflipper手势拖动效果(An-Beer工作室)
Android 的手势拖动切换ViewViewFlipper.doc Eclipse内存不足的解决办法.doc EditView 阻止软键盘自动弹出.doc HttpClient的一个应用的例子(图片下载).txt RatingBar 更换图片.doc TextView 添加超链接.doc ...
Android 的手势拖动切换ViewViewFlipper.doc Eclipse内存不足的解决办法.doc EditView 阻止软键盘自动弹出.doc HttpClient的一个应用的例子(图片下载).txt RatingBar 更换图片.doc TextView 添加超链接.doc ...
露珠/水滴 拖拽 效果 Android工程Demo
还是很有趣的,实现的流畅度没有人家的那么好,我只是模仿这种效果,我写的这个拖拽是两个图标之间进行交换,所以,当从一行的某个位置,换到下一行的另一列的时候,发现有好几个图标都改变位置了,因为是相邻两个...
现下很流行的下拉特效,类似于微信下拉原理,绝对不吭!很好的下拉效果特效。
实现小红书笔记详情图库滑动放大缩小效果,实现原理是设定viewpager的transformer,最后设定viewPager.setPageTransformer(false,dynamicPageTransformer);即可
Android特效按钮点击效果动画从里到外渐变放大散花效果,本例子适合做一些特效的app使用, 使用很简单,直接可以把里面代码拷贝过去, 项目... CircleView实现拖动后圆圈渐变扩大效果。 Android特效按钮点击效果截图
一个java源码实现的Android悬浮框特效,用来模仿有些音乐播放器中的悬浮歌词功能,使用Android Activity并可拖动悬浮框,@author 丸子。触摸点相对于屏幕左上角坐标,这个悬浮歌词框支持更新界面,源代码内支持定义...
主要介绍了Android编程仿Iphone拖动相片特效Gallery的简单应用,结合实例形式分析了Android图形拖动特效的实现步骤与相关操作技巧,需要的朋友可以参考下
Canvas画布点击拖动粒子特效是一款基于html5 canvas制作的通过鼠标点击网页拖动绘制粒子数量特效。
Android 拖动曲线三维拉伸图像,3D图片拉伸特效
Android 小項目之---Iphone拖动图片特效 (附源码) 一个完整的新浪微博客户端android版OAuth认证示例 超爽的android抽屉效果 65个Android实例教程汇总 基本控件及基本动画效果dem 2011android面试题目及其答案大全...
3.15 拖动相片特效 3.16 简易计算器 3.17 about信息 3.18 加载中的程序 3.19 选择对话框 3.20 主题变换 3.21 小结 第4章 andfosd控件演练 4.1 实现文本处理 4.2 将背景图片作为按钮 4.3 用toast实现提示 4.4 用...
3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——多按钮的整合应用 3.17 关于(About)程序信息——Menu功能菜单程序设计 3.18 程序加载中,请稍后——ProgressDialog与线程整合...