简体   繁体   中英

Android Google Maps V2 Marker Click Stuckes The Map View

Im developing an android Tab app using FragmentTabs, A Child Fragment class uses Google Maps V2,

        map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMap();

Once i clicked on a map marker, i need to move to another Child Fragment Class,

        map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

            @Override
            public void onInfoWindowClick(Marker marker) {

                FragmentTransaction transaction = getChildFragmentManager().beginTransaction();                 
                transaction.addToBackStack(null);
                transaction.replace(R.id.container_framelayout, new FragmentClass());
                transaction.commit();
                getChildFragmentManager().executePendingTransactions();
            }
        });

But when i clicked on the marker it freeze my app, i couldn't find any exceptions either..

        map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

            @Override
            public void onInfoWindowClick(Marker marker) {
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();                          
                YourActivity activity = new YourActivity();

                ft.addToBackStack(null);
                ft.replace(R.id.container_framelayout, activity);
                ft.commit();
            }
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM