android – 具有图像的Popupwindow

android – 具有图像的Popupwindow,第1张

概述我需要能够在列表视图中单击一个imgview,这应该打开一个显示图像的大小的d出窗口.我设法实现了clicklistener,但是在创建d出窗口时仍然失败,即使只是一个测试文本视图. 在我的主要活动中,我跑 lstView.setAdapter(new CustomListViewAdapter(this, dataFromDBListe, 0, orientation)); 在我的CustomL 我需要能够在列表视图中单击一个imgvIEw,这应该打开一个显示图像的大小的d出窗口.我设法实现了clickListener,但是在创建d出窗口时仍然失败,即使只是一个测试文本视图.

在我的主要活动中,我跑

lstVIEw.setAdapter(new CustomListVIEwAdapter(this,dataFromDBListe,orIEntation));

在我的CustomListVIEvAdapter中,我有我的clickListener(可以在此时显示吐司),我有以下getVIEw():

public VIEw getVIEw(int position,VIEw convertVIEw,VIEwGroup parent) {    VIEwHolder holder;    if (convertVIEw == null) {        convertVIEw = mInflater.inflate(R.layout.custom_row,null);        holder = new VIEwHolder();        holder.Title = (TextVIEw) convertVIEw.findVIEwByID(R.ID.Title);        holder.prev = (TextVIEw) convertVIEw.findVIEwByID(R.ID.prevNrDate);        holder.prevTitle = (TextVIEw) convertVIEw.findVIEwByID    (R.ID.prevTitle);        holder.next = (TextVIEw) convertVIEw.findVIEwByID(R.ID.nextNrDate);        holder.nextTitle = (TextVIEw) convertVIEw.findVIEwByID     (R.ID.nextTitle);        holder.picture = (ImageVIEw) convertVIEw.findVIEwByID    (R.ID.showPic);        holder.prevFast = (TextVIEw) convertVIEw.findVIEwByID(R.ID.prev);        holder.nextFast = (TextVIEw) convertVIEw.findVIEwByID(R.ID.next);        holder.linearLayout = (linearLayout) convertVIEw.findVIEwByID    (R.ID.imgLay);        convertVIEw.setTag(holder);    } else {        holder = (VIEwHolder) convertVIEw.getTag();    }    testSort(holder);    final Show item = showList.get(position);    holder.Title.setText(item.getTitle());    holder.prev.setText(item.getPrevNr() + " - " + item.getPrevDate());    holder.prevTitle.setText(item.getPrevTitle());    holder.next.setText(item.getNextNr() + " - " + item.getNextDate());    holder.nextTitle.setText(item.getNextTitle());    if(pic) {        holder.linearLayout.setVisibility(8);    } if(compact) {        holder.linearLayout.setVisibility(8);        holder.prevTitle.setVisibility(8);        holder.nextTitle.setVisibility(8);    } else {//          new DownloadImageTask(holder.picture).execute(item.getShowID());        String path;        if(ih.checkimg(item.getShowID())) {            path = PATH + item.getShowID() + ".jpg";        } else {            path = "bla";        }//          DrawableManager dm = new DrawableManager();//          dm.fetchDrawableOnThread(path,holder.picture);        imageDownloader.download(path,holder.picture);//          ih.download(path,holder.picture);    }    holder.picture.setonClickListener(new VIEw.OnClickListener() {                public voID onClick(VIEw vIEw) {                    Toast.makeText(context,"img clicked",Toast.LENGTH_LONG).show();                    //Show popup with full image of the clicked small img.                }            });    return convertVIEw;}

我在这里尝试了大多数常见的链接解决方案的d出窗口,但不能使其工作.

解决方法 创建自定义对话框并在其中传递图像….
private voID loadPhoto(ImageVIEw imageVIEw,int wIDth,int height) {        ImageVIEw tempImageVIEw = imageVIEw;        AlertDialog.Builder imageDialog = new AlertDialog.Builder(this);        LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);        VIEw layout = inflater.inflate(R.layout.custom_fullimage_dialog,(VIEwGroup) findVIEwByID(R.ID.layout_root));        ImageVIEw image = (ImageVIEw) layout.findVIEwByID(R.ID.fullimage);        image.setimageDrawable(tempImageVIEw.getDrawable());        imageDialog.setVIEw(layout);        imageDialog.setPositivebutton(resources.getString(R.string.ok_button),new DialogInterface.OnClickListener(){            public voID onClick(DialogInterface dialog,int which) {                dialog.dismiss();            }        });        imageDialog.create();        imageDialog.show();         }

custom_fullimage_dialog.xml:

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/layout_root" androID:orIEntation="horizontal"    androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"    androID:padding="10dp">    <ImageVIEw androID:ID="@+ID/fullimage" androID:layout_wIDth="fill_parent"        androID:layout_height="fill_parent">    </ImageVIEw>    <TextVIEw androID:ID="@+ID/custom_fullimage_placename"        androID:layout_wIDth="wrap_content" androID:layout_height="fill_parent"        androID:textcolor="#FFF">    </TextVIEw></linearLayout>
总结

以上是内存溢出为你收集整理的android – 具有图像的Popupwindow全部内容,希望文章能够帮你解决android – 具有图像的Popupwindow所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1131438.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存