Category: C #, Android; Date: 2016-02-04 3.3 Use of example 3--mapfragment
First, Introduction
Texturemapfragment: Used to display map fragments.
Second, example 3--demo03mapfragment.cs
File name: Demo02MapFragment.cs
Introduction: Introduction to the use of maps under the fragment framework
Detail: Describes how to add a Texturemapfragment control under the fragment framework;
1. Operation
The effect of running in the x86 simulator is as follows:
2. Design steps
On the basis of the previous example, you only need to add the following steps.
(1) Modify the layout file
Replace the demo02_fragment.xml with the name Demo02_fragment.xml, which is intended to make it easier to observe the layout file for the example.
(2) Add Demo03MapFragment.cs
Add the file under Srcsdkdemos.
usingAndroid.app;usingAndroid.os;usingAndroid.Content.PM;usingCom.Baidu.Mapapi.Map;namespacebdmapv371demos.srcsdkdemos{[Activity (Label="@string/demo_name_map_fragment", Configurationchanges= Configchanges.orientation |Configchanges.keyboardhidden, Screenorientation=screenorientation.sensor)] Public classdemo03mapfragment:activity {Privatetexturemapfragment map; protected Override voidOnCreate (Bundle savedinstancestate) {Base. OnCreate (savedinstancestate); Setcontentview (Resource.Layout.demo03_fragment); Mapstatus Ms=NewMapstatus.builder (). Target (mainactivity.henanuniversity). Overlook ( -) . Zoom ( the) . Build (); Baidumapoptions Bo=Newbaidumapoptions (). Mapstatus (MS). Compassenabled (false) . Zoomcontrolsenabled (true); Map=Texturemapfragment.newinstance (bo); Fragmentmanager.begintransaction (). ADD (Resource.Id.map, map,"map_fragment"). Commit (); } }}
(3) Modify MainActivity.cs
Add the following code in the Demos field definition of the MainActivity.cs file.
// example 3--mapfragment using New Demoinfo<activity>(Resource.String.demo_title_map_fragment, RESOURCE.STRING.DEMO_DESC_MAP_ Fragment, new demo03mapfragment ()),
Run the observation results.
The 3rd chapter in C # to write Baidu map Android mobile app (3rd speaking)