Android的谷歌地图上的位置项单击开始带新活动 [英] Android google map location item click with starting new activity

查看:121
本文介绍了Android的谷歌地图上的位置项单击开始带新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

     map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() 
                    {
                        public void onInfoWindowClick(Marker marker) 
                        {
                           Intent intent = new Intent(NearbyAttractions.this,Activity2.class);
                           intent.putExtra("Clubname", ParseXMLMethods.getValue(e, KEY_TITLE));
                           intent.putExtra("Username", Username);
                           intent.putExtra("ID2", UserID);
                           startActivity(intent);


                        }
                    });

总是最后一个位置名字和我宣布Ë作为最后的变量没有声明最后我得到了一个error.My的要求是,如果我点击特定标记开始新的活动,我HV传递地点名称。

always get the last location name and where I declared e as a final variable without declaring final I got an error.My requirement is if I click on particular marker started new activity where I hv to pass the location name.

推荐答案

信息窗口是不是实时取景所以这个我有什么做的:

InfoWindow isn't a live view so this what i have do :

public class CustomInfoWindowAdpater implements GoogleMap.InfoWindowAdapter,Picasso.Listener {
        @Override
        public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {

        }

        private final View view;

        public CustomInfoWindowAdpater() {
            view = getLayoutInflater()
                    .inflate(R.layout.custominfowindow, null);
        }

        public View getInfoWindow(final Marker marker) {
            MainApplication.currentlyClickedMarker = marker;
            final LinearLayout linearLayout = (LinearLayout)view.findViewById(R.id.ll_custominfowindow);
            linearLayout.setTag(marker.getId());


            GoogleMapFragment.this.marker = marker;

            String url = null;

            if (marker.getId() != null && markers != null && markers.size() > 0) {
                if ( markers.get(marker.getId()) != null &&
                        markers.get(marker.getId()) != null) {
                    url = markers.get(marker.getId());
                }
            }

           final ImageView image = ((ImageView) view.findViewById(R.id.badge));


            //Get the Image from web using Picasso and update the info contents
            if (url != null && !url.equalsIgnoreCase("null")
                    && !url.equalsIgnoreCase("")) {
                Picasso.with(GoogleMapFragment.this).load(Uri.parse(url)).resize(50,50)
                        .into(image, new Callback() {
                            @Override
                            public void onSuccess() {
                                getInfoContents(marker);
                            }

                            @Override
                            public void onError() {

                            }
                        });
            }
            else{
                image.setImageResource(R.drawable.ic_launcher);
            }

            final String title = marker.getTitle();
            final TextView titleUi = ((TextView) view.findViewById(R.id.title));
            if (title != null) {
                titleUi.setText(title);
            } else {
                titleUi.setText("");
            }

            final String snippet = marker.getSnippet();
            final TextView snippetUi = ((TextView) view
                    .findViewById(R.id.snippet));
            if (snippet != null) {
                snippetUi.setText("");
            } else {
                snippetUi.setText("");
            }

            return view;
        }

...

@Override
    public void onCreate(Bundle savedInstanceState) {   
        super.onCreate(savedInstanceState);
     googleMap.setInfoWindowAdapter(new CustomInfoWindowAdpater());
}

...

@Override
    public void onInfoWindowClick(Marker marker) {
        // open the application
        Intent intent = new Intent(GoogleMapFragment.this,SplashScreenAppPro.class);
        // SplashScreen
        intent.putExtra("id",marker.getSnippet());
        intent.putExtra("nom_profil",  marker.getTitle());
        startActivity(intent);


    }

*您活动/片段必须实施 GoogleMap.OnInfoWindowClickListener

这篇关于Android的谷歌地图上的位置项单击开始带新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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