Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 打开带有设备图像的弹出窗口_Android_Google Maps - Fatal编程技术网

Android 打开带有设备图像的弹出窗口

Android 打开带有设备图像的弹出窗口,android,google-maps,Android,Google Maps,我是android开发的新手 我想做的是,我有一张我想在地图上显示的照片列表, 对于每张照片,我将显示一个标记,当点击标记时,照片本身将弹出 到目前为止,我所做的是打开地图并根据照片位置显示标记,现在我实现了一个单击侦听器来显示图像 这是我的代码: googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean o

我是android开发的新手

我想做的是,我有一张我想在地图上显示的照片列表, 对于每张照片,我将显示一个标记,当点击标记时,照片本身将弹出

到目前为止,我所做的是打开地图并根据照片位置显示标记,现在我实现了一个单击侦听器来显示图像

这是我的代码:

googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                // get relevent photo from map
                Photo photo = photoMarkers.get(marker);
                if (photo == null){
                    Log.d("Journee", "photo is null");
                    return false;
                }
                photoPopUp(photo);
                return false;
            }
        })
}


private void photoPopUp(Photo photo) {
    // Inflate the popup
    LayoutInflater inflater = (LayoutInflater)   MapActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.journal_single_image,     (ViewGroup) findViewById(R.id.single_image_popup));

    // show popup
    PopupWindow imagePopup = new PopupWindow(layout, 300, 370, true);
    imagePopup.showAtLocation(layout, Gravity.CENTER, 0, 0);


    // display the photo
    File imgFile = new File(photo.getPathOnDevice());
    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
    ImageView imageView = (ImageView) findViewById(R.id.single_image_full);
    if (imageView == null){
        Log.d("Journee", "imageview is null");
    }else {
        imageView.setImageBitmap(myBitmap);
    }
}
这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:id="@+id/single_image_popup">

<ImageView
    android:layout_width="105dp"
    android:layout_height="wrap_content"
    android:src="@drawable/image_placeholder"
    android:id="@+id/single_image_full"
    android:layout_gravity="center_horizontal"
    android:layout_weight="0.22" />

</LinearLayout>

单击一个标记确实会打开我的弹出窗口,带有默认的图像占位符,但我无法将其替换为我的照片

在代码的最后几行中,我得到imageView为空

thx