首页 新闻 会员 周边 捐助

android GridView+ImageView+TextView,怎样在OnItemClickListener()中得到所点击图片

0
悬赏园豆:100 [已关闭问题] 关闭于 2012-10-24 16:22

我想实现的功能是,点击GridView的Item,把数据(ImageView和TextView的值)传递到对话框中显示,现在我只实现了传递TextView的值,怎样在对话框中显示所点击的图片?

chouzhutou的主页 chouzhutou | 初学一级 | 园豆:11
提问于:2012-10-22 18:12
< >
分享
所有回答(2)
0

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

  v.findViewById(imageViewId).getDrawable();

}

   
povy | 园豆:214 (菜鸟二级) | 2012-10-23 15:13
0
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
final String mImagePath;
mImagePath = path.get(arg2);
File fl=new File(mImagePath);
BitmapFactory.Options opt=new BitmapFactory.Options();
opt.inPreferredConfig=Config.RGB_565;
opt.inPurgeable=true;
opt.inSampleSize=1;
opt.inInputShareable=true;
try {
FileInputStream fin=new FileInputStream(fl);
BufferedInputStream bin=new BufferedInputStream(fin);
Bitmap bm=BitmapFactory.decodeStream(bin,null,opt);
ImageView iv=new ImageView(OrderActivity.this);
iv.setImageBitmap(bm);
iv.setMaxWidth(500);  
 iv.setMaxHeight(500);  
AlertDialog.Builder builder = new Builder(OrderActivity.this);
builder.setView(iv);
builder.setPositiveButton("确定",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertDialog = builder.create();  
alertDialog.show();  
WindowManager m = getWindowManager(); 
Display d = m.getDefaultDisplay(); 
WindowManager.LayoutParams p = getWindow().getAttributes(); 
p.height = (int) (d.getHeight() * 0.6); 
p.width = (int) (d.getWidth() * 0.8); 
alertDialog.getWindow().setAttributes(p);  
bin.close();
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} 
return true;
}
        
chouzhutou | 园豆:11 (初学一级) | 2012-10-24 16:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册