当前位置:操作系统 > 安卓/Android >>

设置联系人头像的图片

icon  = (ImageView) findViewById(R.id.icon);
        icon.setBackgroundResource(R.drawable.icos6);
       
        icon.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Display display = getWindowManager().getDefaultDisplay();
                View popupWview = getLayoutInflater().inflate(R.layout.activity_getPhoto, null);
                final PopupWindow alert = new PopupWindow(popupWview,
                        display.getWidth(),LinearLayout.LayoutParams.WRAP_CONTENT, true);
                alert.showAtLocation(v, Gravity.BOTTOM, 0, 0);

                LinearLayout touxiang = (LinearLayout) popupWview
                        .findViewById(R.id.touxiang);
                alert.setFocusable(true);
              touxiang.setOnKeyListener(new OnKeyListener() {

                    public boolean onKey(View v, int keyCode, KeyEvent event) {

                        if (event.getAction() == KeyEvent.ACTION_DOWN
                                && keyCode == KeyEvent.KEYCODE_BACK)
                            alert.dismiss();
                        return false;
                    }

                });
                Button paizhao = (Button) popupWview
                        .findViewById(R.id.paizhao);
                paizhao.setOnClickListener(new OnClickListener() {

                    public void onClick(View v) {
                        try {
                            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                            File out = new File(Environment.getExternalStorageDirectory(),"camera.jpg");
                            Uri uri = Uri.fromFile(out);
                            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                            startActivityForResult(intent, 0);
                            } catch (Exception e) {
                            e.printStackTrace();
                            }
                         alert.dismiss();
                    }
                });
                Button xiangce = (Button) popupWview
                        .findViewById(R.id.xiangce);
                congxiangcehuoqu.setOnClickListener(new OnClickListener() {

                    public void onClick(View v) {
                        Intent intent = new Intent();
                        intent.setType("image/*");
                        intent.setAction(Intent.ACTION_GET_CONTENT);
                        /* 取得相片后返回本画面 */
                        startActivityForResult(intent, 2);
                        alert.dismiss();
                    }
                });
                Button quxiao = (Button) popupWview
                        .findViewB

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,