0

多数のジオポイントがあり、ジオポイントが選択されると、ジオポイントの上にレイアウトが膨らみ、その場所に関するユーザーの詳細が表示されます。infalted レイアウト内に imageButton がありますが、クリックできないようで、その理由がわかりません! 以下に、私が作成したコードを示します。このコードは、マップに関心のあるポイントを追加し、膨張したレイアウトに情報を入力します。

//show the place markers on map.
    for (int i = 0; i<mListPlaceData.size(); i++){
        PlaceData data = mListPlaceData.get(i);
        data.marker = mMap.addMarker(new MarkerOptions().position(new LatLng(data.lat, data.lon)).
                icon(BitmapDescriptorFactory.fromResource(R.drawable.place_mark))); //show place mark on map
        data.marker.setSnippet(String.valueOf(i));//set index of the data
        mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

            @Override
            public View getInfoWindow(Marker arg0) {

                return null;
            }

            @Override
            public View getInfoContents(Marker arg0) {
                View v = getLayoutInflater().inflate(R.layout.place_detail, null);
                String pos = arg0.getSnippet(); //get index of the marker data
                try{
                    int ipos = Integer.parseInt(pos);
                    PlaceData data = mListPlaceData.get(ipos); //get the data by index
                    ((TextView)v.findViewById(R.id.txtName)).setText(data.name); //show name of the place
                    ((TextView)v.findViewById(R.id.txtHours)).setText("Hours: "+data.hours); //show hours of the place
                    ((TextView)v.findViewById(R.id.txtCountry)).setText("Country: "+data.country); //show country of the place
                    ((TextView)v.findViewById(R.id.txtAddress)).setText("Address: "+data.address); //show address of the place
                    ((TextView)v.findViewById(R.id.txtPostCode)).setText("Postcode: "+ data.postcode); //show postcode of the place

                    View.OnClickListener imageDirections = new View.OnClickListener() {
                        public void onClick(View v) {
                            Toast.makeText(TrackingServiceActivity.this,
                                    "ImageButton is clicked!", Toast.LENGTH_SHORT).show();
                        }
                      };


                      imageButton = (ImageButton) v.findViewById(R.id.imageButton1);
                      imageButton.setOnClickListener(imageDirections);

                }catch(Exception e){

                }
                return v;
            }
        });

    }
4

1 に答える 1