2
googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
    public void onInfoWindowClick(Marker marker) {
        Intent rest_list = new Intent(getParent(), RestFullDetail.class);
        TabGroupActivity parentActivity = (TabGroupActivity)getParent();
        parentActivity.startChildActivity("mapRestDetail", rest_list);
    }
});

当我点击信息窗口时,信息窗口冻结并且不会导航到另一个选项卡子活动。在冻结和崩溃时,它不会产生任何 logcat 信息。

得到解决方案:

我自己找到了解决方案。尝试在 infowindowclick 上执行异步任务,并将所有代码(在 info window click 下运行)放在 postexecute 中。它就像魅力一样。

4

1 回答 1

0

您需要按照以下步骤执行自定义信息窗口单击:

--> 实现“GoogleMap.OnInfoWindowClickListener”“GoogleMap.InfoWindowAdapter”

--> 膨胀自定义信息窗口:

@Override
    public View getInfoContents(Marker marker) {
        // Inflate the layouts for the info window, title and snippet.
        View infoWindow = getActivity().getLayoutInflater().inflate(R.layout.custom_info_contents, null);
        TextView txtStoreName = ((TextView) infoWindow.findViewById(R.id.txtStoreName));
        txtStoreName.setText(marker.getTitle());
        TextView txtStoreAddress = ((TextView) infoWindow.findViewById(R.id.txtStoreAddress));
        txtStoreAddress.setText(marker.getSnippet());
        return infoWindow;
    }

--> 设置监听器:// InfoWindowClick

mGoogleMap.setOnInfoWindowClickListener(this);
    @Override
        public void onInfoWindowClick(final Marker marker) {
            // TODO Here perform action on balloon view click
            mRecyclerStore.post(new Runnable() {
                @Override
                public void run() {
                    StoreModel model = (StoreModel) marker.getTag();
                    boolean isAddedToBackStack = true;
                    StoreDetailsAndProductListFragment storeDetailsAndProductListFragment = new StoreDetailsAndProductListFragment();
                    Bundle bundle = new Bundle();
                    bundle.putParcelable(ExtrasUtil.STORE, model);
                    storeDetailsAndProductListFragment.setArguments(bundle);
                    showOtherFragment(storeDetailsAndProductListFragment, getActivity().getFragmentManager(), isAddedToBackStack);
                }
            });
        }
于 2017-11-29T11:30:16.953 回答