需要向infowindow添加解析用户名

时间:2016-08-01 16:20:54

标签: android google-maps marker

是否可以在google maps infowindow中为TextView添加用户名?

在下面的代码中,我能够从解析中获取标题,描述和图像,我想将当前用户添加到textview但我无法做到。我正在寻找的是一些指导,因为没有很多关于这个的帖子(或许我需要进入深度网络)她是我的代码供参考

@Override
    public void onMapReady(final GoogleMap googleMap) {
        googleMap.setMyLocationEnabled(true);
        this.googleMap = googleMap;
        googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

            // Use default InfoWindow frame
            @Override
            public View getInfoWindow(Marker arg0) {
                return null;
            }

            // Defines the contents of the InfoWindow
            @Override
            public View getInfoContents(Marker marker) {

                // Getting view from the layout file info_window_layout
                View v = getActivity().getLayoutInflater().inflate(R.layout.maps_infowindow, null);
                v.setLayoutParams(new LinearLayout.LayoutParams((int) (mapFragment.getView().getMeasuredWidth() * .9), LinearLayout.LayoutParams.WRAP_CONTENT));

                ((TextView) v.findViewById(R.id.title)).setText(marker.getTitle());
                ((TextView) v.findViewById(R.id.desc)).setText(marker.getSnippet());
                ((TextView) v.findViewById(R.id.user)).setText((CharSequence) ParseUser.getCurrentUser()); // PROBLEM HERE



                Item item = mMarker2Item.get(marker);
                if(item.iconBitmap==null){
                    //this is a blocking call, it will run until download complete
                    item.downloadIcon(getActivity());
                }

                ImageView icon = (ImageView) v.findViewById(R.id.imageView5);
                icon.getLayoutParams().height = 800; // OR
                icon.getLayoutParams().width = 800;

                if(item.iconBitmap!=null){
                    icon.setImageBitmap(item.iconBitmap);
                }else{
                }

                return v;

            }

        });

1 个答案:

答案 0 :(得分:0)

啊好的简单的东西。我所要做的就是从解析中获取用户字符串并将其设置为我的textView,如下所示:

 String user = ParseUser.getCurrentUser().getString("username");
                ((TextView) v.findViewById(R.id.user)).setText(user);