显示图库

时间:2013-06-03 09:59:00

标签: android android-layout

当我点击galleryview中的图片时,我想显示我从中选择的图片。我做了一个吐司,给了我点击的图片,但我想在另一个活动中展示它。

我该怎么做?

这是我的画廊活动。

 public View getView(int position, View convertView, ViewGroup parent) {   
                inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View vi=convertView;   
                final Players players = getItem(position);


                if(convertView==null){  


                    vi = inflater.inflate(R.layout.pictures, null); 

                    ImageView image=(ImageView) vi.findViewById(R.id.imageView1);

                    TextView text1=(TextView)vi.findViewById(R.id.textView1);  
                    TextView text2=(TextView)vi.findViewById(R.id.textNom);
                    TextView text3=(TextView)vi.findViewById(R.id.textPost);
                    TextView text4=(TextView)vi.findViewById(R.id.textDdn);

                    text1.setText(players.getNm()); 
                    text2.setText(Html.fromHtml( players.getNom()).toString());
                    text3.setText(Html.fromHtml( players.getPost()).toString().replace("Ž", "é"));
                    text4.setText(players.getDdn());

                    imageLoader.displayImage(players.getImage()image,options);


                galleryView.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> arg0, View view, int position,long arg3) {
                        Toast.makeText(getApplicationContext(), players.getImage() , Toast.LENGTH_SHORT).show();

                    }
                });
            }

这就是我在其他活动中所做的事情,让我有问题表明:

class ImageAdapter extends ArrayAdapter<Players> {

    public ImageAdapter(Context context, int textViewResourceId,List<Players> objects) {
        super(context, textViewResourceId, objects);
    }

    public View getView(int position, View convertView, ViewGroup parent) {   
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View vi=convertView;   

        Players players = getItem(position);

        if(convertView==null){  

            vi = inflater.inflate(R.layout.gallery_player, null); 

            imageLoader.displayImage(players.getImage(), img, options);
        }
        return vi;
    }
}
}

1 个答案:

答案 0 :(得分:1)

有几种方法, 我不确定您是如何设计数据的, 一个简单的解决方案,
您可以使用图像网址

为所有ImageView设置标记
 view.setTag(url)  

每当您点击imageview时,您都可以获得标签,即ImageUrl,

  view.getTag()

将url发送到其他活动并读取位图并将其显示在ImageView中或根据需要显示在背景中。