The 3rd chapter in C # to write Baidu map Android mobile app (3rd speaking)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.