fragment+Map - ERROR ?

Manu4uManu4u USMember
edited July 2016 in Xamarin.Android

I started learning Xamarin from few days, using Visual Studio 2015 IDE with Xamarin, lacking in knowledge, i am unable to solve this..

Working on Map Task, using fragment

Severity Code Description Project File Line Suppression State
Warning The element 'LinearLayout' has invalid child element 'fragment'. List of possible elements expected: 'GLSurfaceView, AdapterView, AdapterViewAnimator, AutoCompleteTextView, MediaController, TextView, FragmentBreadCrumbs, AppWidgetHostView, GestureOverlayView, ExtractEditText, KeyboardView, RSSurfaceView, RSTextureView, SurfaceView, TextureView, ViewGroup, ViewStub, WebView, AbsListView, AbsSeekBar, AbsSpinner, AbsoluteLayout, AdapterViewFlipper, AnalogClock, Button, CalendarView, CheckBox, CheckedTextView, Chronometer, CompoundButton, DatePicker, DialerFilter, DigitalClock, EditText, ExpandableListView, FrameLayout, Gallery, GridLayout, GridView, HorizontalScrollView, ImageButton, ImageSwitcher, ImageView, LinearLayout, ListView, MultiAutoCompleteTextView, NumberPicker, ProgressBar, QuickContactBadge, RadioButton, RadioGroup, RatingBar, RelativeLayout, ScrollView, SearchView, SeekBar, SlidingDrawer, Space, Spinner, StackView, Switch, TabHost, TabWidget, TableLayout, TableRow, TextSwitcher, TimePicker, ToggleButton, TwoLineListItem, VideoView, ViewAnimator, ViewFlipper, ViewSwitcher, ZoomButton, ZoomControls'. googlemap C:\Users\googlemap\Resources\layout\Main.axml 6

or
if i build and trying to run.. i will get as below,

"Android.Views.InflateException:Binary XML file line #1: Error inflating class fragment.

and i added Xamarin.Android.Support.v4 and Xamarin.Android.Support.v7 but not getting.

the code as below..

Main.axml

<?xml version="1.0" encoding="utf-8"?>

Activity.cs

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Gms.Maps;
using Android.Gms.Maps.Model;

namespace googlemap
{
[Activity(Label = "googlemap", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity, IOnMapReadyCallback
{

private GoogleMap GMap;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);

// Get our button from the layout resource,
// and attach an event to it
SetUpMap();

}

private void SetUpMap()
{
if (GMap == null)
{
FragmentManager.FindFragmentById(Resource.Id.googlemap).GetMapAsync(this);

}

}
public void OnMapReady(GoogleMap googleMap)
{
this.GMap = googleMap;
GMap.UiSettings.ZoomControlsEnabled = true;

LatLng latlng = new LatLng(Convert.ToDouble(13.0291), Convert.ToDouble(80.2083));
CameraUpdate camera = CameraUpdateFactory.NewLatLngZoom(latlng, 15);
GMap.MoveCamera(camera);


MarkerOptions options = new MarkerOptions()
            .SetPosition(latlng)
            .SetTitle("Chennai");

GMap.AddMarker(options);

}
}
}

Sign In or Register to comment.