Popupwindow与图像 [英] Popupwindow with image

查看:143
本文介绍了Popupwindow与图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够单击 imgview 列表视图,应该会打开一个弹出窗口显示的图像全尺寸。我已经成功地实施 clicklistener ,但要拜倒在创建弹出,即使只有一个测试的TextView

I need to be able to click an imgview in a listview, which should open a popup showing the image fullsize. I've managed to implement the clicklistener, but keep failing at creating the popup, even with just a testing textview.

在我mainActivity的onCreate我运行

In my mainActivity oncreate i run

lstView.setAdapter(new CustomListViewAdapter(this, dataFromDBListe, 0, orientation));

在我CustomListVievAdapter,在那里我有我的clicklistener(可显示举杯的时刻)我有以下 getView()

In my CustomListVievAdapter, where i have my clicklistener (which can display a toast at the moment) I have the following 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;
}

我想大部分的常用linkedto解决方案在这里popupwindow,但不能使它工作。

I tried most of the commonly linkedto solutions in here for popupwindow, but can't make it work.

推荐答案

创建自定义对话框,并通过图像在里面......

Create custom-dialog and pass image in it....

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:

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>

这篇关于Popupwindow与图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆