代码片段 (2)
[代码] FlingGalleryActivity
import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TextView;
public class FlingGalleryActivity extends Activity
{
private final int color_red = Color.argb(100, 200, 0, 0);
private final int color_green = Color.argb(100, 0, 200, 0);
private final int color_blue = Color.argb(100, 0, 0, 200);
private final int color_yellow = Color.argb(100, 200, 200, 0);
private final int color_purple = Color.argb(100, 200, 0, 200);
private final String[] mLabelArray = {"View1", "View2", "View3", "View4", "View5"};
private final int[] mColorArray = {color_red, color_green, color_blue, color_yellow, color_purple};
private FlingGallery mGallery;
private CheckBox mCheckBox;
// Note: The following handler is critical to correct function of
// the FlingGallery class. This enables the FlingGallery class to
// detect when the motion event has ended by finger being lifted
@Override
public boolean onTouchEvent(MotionEvent event)
{
return mGallery.onGalleryTouchEvent(event);
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mGallery = new FlingGallery(this);
mGallery.setPaddingWidth(5);
mGallery.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, mLabelArray)
{
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("111", "count="+position);
// if (convertView != null && convertView instanceof GalleryViewItem)
// {
// GalleryViewItem galleryView = (GalleryViewItem) convertView;
//
// galleryView.mEdit1.setText("");
// galleryView.mText1.setText(mLabelArray[position]);
// galleryView.mText1.setBackgroundColor(mColorArray[position]);
// galleryView.mText2.setText(mLabelArray[position]);
// galleryView.mText2.setBackgroundColor(mColorArray[position]);
//
// Log.d("111", "count="+position);
//
// return galleryView;
//
// }
return new GalleryViewItem(getApplicationContext(), position);
}
});
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.weight = 1.0f;
layout.addView(mGallery, layoutParams);
mCheckBox = new CheckBox(getApplicationContext());
mCheckBox.setText("Gallery is Circular");
mCheckBox.setText("Gallery is Circular");
mCheckBox.setPadding(50, 10, 0, 10);
mCheckBox.setTextSize(30);
mCheckBox.setChecked(true);
mCheckBox.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
mGallery.setIsGalleryCircular(mCheckBox.isChecked());
}
});
layout.addView(mCheckBox, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
setContentView(layout);
}
private class GalleryViewItem extends TableLayout
{
private EditText mEdit1;
private TextView mText1;
private TextView mText2;
private Button mButton1;
private Button mButton2;
public GalleryViewItem(Context context, int position)
{
super(context);
this.setOrientation(LinearLayout.VERTICAL);
this.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
mEdit1 = new EditText(context);
this.addView(mEdit1, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mText1 = new TextView(context);
mText1.setText(mLabelArray[position]);
mText1.setTextSize(30);
mText1.setGravity(Gravity.LEFT);
mText1.setBackgroundColor(mColorArray[position]);
this.addView(mText1, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mButton1 = new Button(context);
mButton1.setText("<<");
mButton1.setGravity(Gravity.LEFT);
mButton1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
mGallery.movePrevious();
}
});
this.addView(mButton1, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mButton2 = new Button(context);
mButton2.setText(">>");
mButton2.setGravity(Gravity.RIGHT);
mButton2.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
mGallery.moveNext();
}
});
this.addView(mButton2, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mText2 = new TextView(context);
mText2.setText(mLabelArray[position]);
mText2.setTextSize(30);
mText2.setGravity(Gravity.RIGHT);
mText2.setBackgroundColor(mColorArray[position]);
this.addView(mText2, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, 1));
}
}
}
[代码] FlingGallery
import android.content.Context;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.Transformation;
import android.widget.Adapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
// TODO:
// 1. In order to improve performance Cache screen bitmap and use for animation
// 2. Establish superfluous memory allocations and delay or replace with reused objects
// Probably need to make sure we are not allocating objects (strings, etc.) in loops
public class FlingGallery extends FrameLayout
{
// Constants
private final int swipe_min_distance = 120;
private final int swipe_max_off_path = 250;
private final int swipe_threshold_veloicty = 400;
// Properties
private int mViewPaddingWidth = 0;
private int mAnimationDuration = 250;
private float mSnapBorderRatio = 0.5f;
private boolean mIsGalleryCircular = true;
// Members
private int mGalleryWidth = 0;
private boolean mIsTouched = false;
private boolean mIsDragging = false;
private float mCurrentOffset = 0.0f;
private long mScrollTimestamp = 0;
private int mFlingDirection = 0;
private int mCurrentPosition = 0;
private int mCurrentViewNumber = 0;
private Context mContext;
private Adapter mAdapter;
private FlingGalleryView[] mViews;
private FlingGalleryAnimation mAnimation;
private GestureDetector mGestureDetector;
private Interpolator mDecelerateInterpolater;
public FlingGallery(Context context)
{
super(context);
mContext = context;
mAdapter = null;
mViews = new FlingGalleryView[3];
mViews[0] = new FlingGalleryView(0, this);
mViews[1] = new FlingGalleryView(1, this);
mViews[2] = new FlingGalleryView(2, this);
mAnimation = new FlingGalleryAnimation();
mGestureDetector = new GestureDetector(new FlingGestureDetector());
mDecelerateInterpolater = AnimationUtils.loadInterpolator(mContext, android.R.anim.decelerate_interpolator);
}
public void setPaddingWidth(int viewPaddingWidth)
{
mViewPaddingWidth = viewPaddingWidth;
}
public void setAnimationDuration(int animat
没有合适的资源?快使用搜索试试~ 我知道了~
开源代码下载软件 net
共146个文件
txt:140个
dll:2个
exe:2个
1星 需积分: 9 3 下载量 97 浏览量
2011-04-15
15:45:15
上传
评论
收藏 196KB RAR 举报
温馨提示
开源代码下载软件 net 开源爱好者的最爱了
资源推荐
资源详情
资源评论
收起资源包目录
开源代码下载软件 net (146个子文件)
Tools.dll 6KB
EnumPara.dll 4KB
Open Source Code Download.exe 43KB
Open Source Code Download.vshost.exe 14KB
Open Source Code Download.vshost.exe.manifest 490B
Open Source Code Download.pdb 36KB
android实现uc和墨迹天气那样的左右拖动效果.txt 22KB
android实现uc和墨迹天气那样的左右拖动效果.txt 22KB
Java 的 ComponentOrientation 类使用方法.txt 12KB
android播放gif图片.txt 10KB
android播放gif图片.txt 10KB
android手势识别ViewFlipper触摸动画.txt 7KB
android手势识别ViewFlipper触摸动画.txt 7KB
J2ME中RMS的使用解析.txt 6KB
J2ME中RMS的使用解析.txt 6KB
J2ME中RMS的使用解析.txt 6KB
Android 的 MediaPlayer 多媒体播放器.txt 6KB
J2ME:沉睡的小狗.txt 6KB
J2ME 的 RMS 使用一例:BookStore.txt 5KB
J2ME 的 RMS 使用一例:BookStore.txt 5KB
J2ME 的 RMS 使用一例:BookStore.txt 5KB
J2ME 的 RMS 使用一例:BookStore.txt 5KB
Android 的 SurfaceView 双缓冲应用.txt 5KB
ObtainQuoteMIDlet.txt 5KB
ObtainQuoteMIDlet.txt 5KB
ObtainQuoteMIDlet.txt 5KB
ObtainQuoteMIDlet.txt 5KB
ObtainQuoteMIDlet.txt 5KB
终极密码游戏.txt 5KB
终极密码游戏.txt 5KB
Android 滑动加载数据.txt 5KB
Android SurfaceView 的基本应用.txt 4KB
Java 解析 lnk 快捷方式文件的方法.txt 3KB
使用 Android Layouts 和 ListViews.txt 3KB
使用 Android Layouts 和 ListViews.txt 3KB
Android 轻松实现语音识别.txt 3KB
Android 轻松实现语音识别.txt 3KB
Android GridView的使用.txt 3KB
Android GridView的使用.txt 3KB
Android 使用 SMTP 发送邮件 (Gmail).txt 3KB
Android 使用 SMTP 发送邮件 (Gmail).txt 3KB
Android 使用 SMTP 发送邮件 (Gmail).txt 3KB
j2me跳转到高级界面获得输入法.txt 3KB
j2me跳转到高级界面获得输入法.txt 3KB
j2me自动适应文字分段.txt 2KB
j2me自动适应文字分段.txt 2KB
纯属娱乐,对入门Android有一定的帮助.txt 2KB
纯属娱乐,对入门Android有一定的帮助.txt 2KB
处理 Android 手机的震动事件.txt 2KB
J2ME 的 RMS 测试一例.txt 2KB
J2ME 的 RMS 测试一例.txt 2KB
J2ME 的 RMS 测试一例.txt 2KB
J2ME 的 RMS 测试一例.txt 2KB
我的 Java 线程池测试类.txt 2KB
Android通过手势实现的缩放处理.txt 2KB
Android通过手势实现的缩放处理.txt 2KB
Android intent 之间的相互调用.txt 2KB
Android intent 之间的相互调用.txt 2KB
Android访问php取回json数据.txt 2KB
请求网络数据后更新视图.txt 2KB
Java 根据 HashMap 的 value 进行排序.txt 2KB
Java 根据文件中定义的时间执行信息提醒.txt 2KB
Java 处理从右向左的阅读顺序 (Right Format).txt 1KB
SurfaceView 程序效果:用线程画一个蓝色的长方形。.txt 1KB
SurfaceView 程序效果:用线程画一个蓝色的长方形。.txt 1KB
SurfaceView 程序效果:用线程画一个蓝色的长方形。.txt 1KB
我的 Java 线程本地测试类 (ThreadLocal).txt 1KB
Android 使用 Gmail 来发送邮件.txt 1KB
Android 使用 Gmail 来发送邮件.txt 1KB
Android隐藏状态栏和标题栏,相当于全屏效果.txt 1KB
Android隐藏状态栏和标题栏,相当于全屏效果.txt 1KB
J2ME小特效之波浪字体.txt 1KB
J2ME小特效之波浪字体.txt 1KB
Android重力感应器Sensor编程.txt 1KB
Android重力感应器Sensor编程.txt 1KB
Android button 居中.txt 1KB
Android button 居中.txt 1KB
Java 使用 ParsePosition 类的另外一个例子.txt 1KB
检测手机用户安装的应用程序是否有使用某权限.txt 1KB
检测手机用户安装的应用程序是否有使用某权限.txt 1KB
J2ME小特效之闪电中的城市.txt 1KB
J2ME小特效之闪电中的城市.txt 1KB
实现 Android 应用在开机时自启动.txt 1KB
实现 Android 应用在开机时自启动.txt 1KB
J2ME 在MIDP中实现图片放缩.txt 1KB
J2ME 在MIDP中实现图片放缩.txt 1KB
J2ME 在MIDP中实现图片放缩.txt 1KB
在 Android 上使用 jspf 插件框架.txt 1KB
j2me发短信.txt 952B
j2me发短信.txt 952B
j2me发短信.txt 952B
检测 Android 中的某个 Intent 是否有效.txt 872B
检测 Android 中的某个 Intent 是否有效.txt 872B
Java 使用正则表达式从文件中解析出所有email地址.txt 814B
J2ME 的 RecordListener 类使用方法.txt 756B
J2ME 的 RecordListener 类使用方法.txt 756B
Android Splash Screen.txt 669B
Android Splash Screen.txt 669B
Android Splash Screen.txt 669B
Android Splash Screen.txt 669B
共 146 条
- 1
- 2
资源评论
- E诺千金2012-10-24一窍不通呀,我搜的是.net的可是里面全是JAVA
hbsoft2008
- 粉丝: 24
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功