onclick() for the waterfall item

豌豆荚截图20121214090537.png豌豆荚截图20121214090550.png

private void AddImage(String filename, int columnIndex) {
ImageView item = (ImageView) LayoutInflater.from(this).inflate(
R.layout.waterfallitem, null);

waterfall_items.get(columnIndex).addView(item);
param = new TaskParam();
param.setAssetManager(assetManager);
param.setFilename(image_path + “/” + filename);
param.setItemWidth(itemWidth);
ImageLoaderTask task = new ImageLoaderTask(item);
item.setTag(filename);
item.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(MainActivity.this, PicBrowserActivity.class);
Bundle b=new Bundle();
b.putString(“fileName”,(String) v.getTag());
intent.putExtras(b);
startActivity(intent);
}
});
task.execute(param);
}
其实里面有用的也就是item.setTag(fileName);
在监听器中得到绑定的tag也就能得到点击的图片名字
然后就可以跳转页面,到该页面浏览图片了
其中要注意的是fileName的值只是文件的名字
网上例子DEMO的图片放在assets文件夹下的images文件夹下  所以加载图片的时候要在名字前面加上images/的路径

MainActivity:
private void AddImage(final String filename, int rowIndex, final int id) {
FlowView item = new FlowView(context);
// item.setColumnIndex(columnIndex);
item.setRowIndex(rowIndex);
item.setId(id);
item.setViewHandler(this.handler);
// 多线程参数
FlowTag param = new FlowTag();
param.setFlowId(id);
param.setAssetManager(asset_manager);
param.setFileName(image_path + “/” + filename);
param.setItemWidth(item_width);
item.setFlowTag(param);
item.LoadImage();
item.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this, TestActivity.class);
intent.putExtra(“id”, id);;
intent.putExtra(“filename”, filename);
startActivity(intent);
}
});
// waterfall_items.get(columnIndex).addView(item);
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: