简体   繁体   中英

When i click on particular data(location) in the first fragment i want to navigate to the second fragment and show a marker on the map and data

I have two fragments implemented using View Pager . In fragment 1 I have list of data with the location coordinates and in fragment 2 I have map, which is showing all data according to the location coordinates.

When I click on particular data in the first fragment I want the app to navigate to the second fragment and shows a marker on the map and data in the info window.

When I click on particular data I am able to move on the second fragment using setcurrentitem() method. But how do I show that particular location only?

If anybody knows, please suggest me a solution. I need to do this as soon as possible.

Thanks

While you are calling setcurrentitem() , pass Latitude and Longitude data to Fragment 2, put this code in Fragment 1:

    Fragment2 f = new Fragment2();

    // Supply value
    Bundle args = new Bundle();
    args.putLong("latitude", location.getLatitude());
    args.putLong("longitude", location.getLongitude());
    f.setArguments(args);

Fetch value in Fragment 2 :

    Long latitude = getArguments().getLong("latitude", 0);
    Long longitude = getArguments().getLong("longitude", 0);

Using latitude and longitude , you can show marker on Google Map in Fragment 2

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