• 点击头像显示大图Dialog


    1、实现效果

    点击头像 弹出全屏dialog,长按图片弹出“保存图片对话框”,短按dialog消失。

    package com.example.widget;
    
    import android.app.Dialog;
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnLongClickListener;
    import android.widget.ImageView;
    
    import com.kuangren.real.R;
    import com.will.ui.view.ChatDialog;
    
    public class HeadDialog extends Dialog {
    
        private ImageView imageView;
        Context context;
        private Bitmap bitmap;
    
        public HeadDialog(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
            this.context = context;
        }
    
        public HeadDialog(Context context, int theme) {
            super(context, theme);
            this.context = context;
        }
    
        private ChatDialog alertDialog;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            this.setContentView(R.layout.head_dialog);
            imageView = (ImageView) findViewById(R.id.dialog_head);
            if(bitmap!=null){
                imageView.setImageBitmap(bitmap);
            }
            // 这里要写全,
            imageView.setOnClickListener(new android.view.View.OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    HeadDialog.this.dismiss();
                }
            });
            imageView.setOnLongClickListener(new OnLongClickListener() {
    
                @Override
                public boolean onLongClick(View arg0) {
                    // TODO Auto-generated method stub
    
                    alertDialog.show();
    
                    return false;
                }
            });
        }
    
        public ImageView getImageView() {
            return imageView;
        }
    
        public ChatDialog getAlertDialog() {
            return alertDialog;
        }
    
        public void setAlertDialog(ChatDialog alertDialog) {
            this.alertDialog = alertDialog;
        }
    
        public Bitmap getBitmap() {
            return bitmap;
        }
    
        public HeadDialog setBitmap(Bitmap bitmap) {
            this.bitmap = bitmap;
            return this;
        }
    
    }

    调用

    HeadDialog dialog =new 
    dialog.setAlertDialog(alertDialog);
    dialog.setBitmap(bitmap).show();

    注意:

    android.view.View.OnClickListener与content.DialogInterface.OnClickListener()冲突

    使用时带上全路径

  • 相关阅读:
    Redis-10 Bitmap位图基本操作
    Redis学习-09 hyperloglog基本操作
    Redis学习-08 Geospatial地理位置详解
    Redis学习-07 Zset有序集合
    Redis学习-06 Hash哈希基本操作
    部分知识路径
    Docker 容器中安装vi、ifconfig、ping命令
    Java new一个对象的过程超级详解
    SVN
    创建ssm项目
  • 原文地址:https://www.cnblogs.com/xingyyy/p/4278942.html
Copyright © 2020-2023  润新知