How to render UI controls in Xamarin Forms equivalent to Android native controls?










0














I am planning to integrate Phunware map within Xamarin Forms app. I am able to create Android Binding project so I can get packages equivalent to Phunware Android native SDK. By this I am able to access all methods and classes of Phunware SDK. Now the challenge is I have to follow Phunware Android native sample app source code, write equivalent code in Xamarin Forms and bring the map. I have given Android UI xml and activity file for sample.



 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.phunware.java.sample.LoadBuildingActivity">

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.phunware.mapping.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignTop="@id/map"
android:background="@color/white"
android:orientation="vertical"
android:padding="6dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/switch_floors" />

<Spinner
android:id="@+id/floorSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

</RelativeLayout>

package com.landt.ismartphunware2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.phunware.core.PwCoreSession;
//import com.phunware.java.sample.R;
import com.phunware.mapping.MapFragment;
import com.phunware.mapping.OnPhunwareMapReadyCallback;
import com.phunware.mapping.PhunwareMap;
import com.phunware.mapping.manager.Callback;
import com.phunware.mapping.manager.PhunwareMapManager;
import com.phunware.mapping.model.Building;
import com.phunware.mapping.model.FloorOptions;

public class LoadBuildingActivity extends AppCompatActivity implements OnPhunwareMapReadyCallback
private static final String TAG = LoadBuildingActivity.class.getSimpleName();
private PhunwareMapManager mapManager;
private Building currentBuilding;
private ArrayAdapter<FloorOptions> spinnerAdapter;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.load_building);

Spinner floorSpinner = findViewById(R.id.floorSpinner);
spinnerAdapter = new FloorAdapter(this);
floorSpinner.setAdapter(spinnerAdapter);
floorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
FloorOptions floor = spinnerAdapter.getItem((int) id);
if (currentBuilding != null && floor != null)
currentBuilding.selectFloor(floor.getLevel());



@Override
public void onNothingSelected(AdapterView<?> parent)

);

// Create the map manager used to load the building
mapManager = PhunwareMapManager.create(this);

// Register the Phunware API keys
PwCoreSession.getInstance().registerKeys(this);

MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
if (mapFragment != null)
mapFragment.getPhunwareMapAsync(this);



@Override
public void onPhunwareMapReady(final PhunwareMap phunwareMap)
// Retrieve buildingId from integers.xml
int buildingId = getResources().getInteger(R.integer.buildingId);

mapManager.setPhunwareMap(phunwareMap);
mapManager.addBuilding(buildingId,
new Callback<Building>()
@Override
public void onSuccess(Building building)
Log.d(TAG, "Building loaded successfully");
currentBuilding = building;

// Populate floor spinner
spinnerAdapter.clear();
spinnerAdapter.addAll(building.getBuildingOptions().getFloors());

// Set building to initial floor value
FloorOptions initialFloor = building.initialFloor();
building.selectFloor(initialFloor.getLevel());

// Animate the camera to the building at an appropriate zoom level
CameraUpdate cameraUpdate = CameraUpdateFactory
.newLatLngBounds(initialFloor.getBounds(), 4);
phunwareMap.getGoogleMap().animateCamera(cameraUpdate);


@Override
public void onFailure(Throwable throwable)
Log.d(TAG, "Error when loading building -- " + throwable.getMessage());

);




Here, they are casting UI control to MapFragment and calling getPhunwareMapAsync() method. I just want to know in Xamarin Forms what control we can map to this MapFragment? In case we are about to write equivalent code in MainActivity of Xamarin Android project, how can we establish connection between PCL project and Android project and bring the map in View? I am just trying to figure out how to start and what to put where as I have excellent experience in Xamarin Forms but less experience with Android Native.










share|improve this question


























    0














    I am planning to integrate Phunware map within Xamarin Forms app. I am able to create Android Binding project so I can get packages equivalent to Phunware Android native SDK. By this I am able to access all methods and classes of Phunware SDK. Now the challenge is I have to follow Phunware Android native sample app source code, write equivalent code in Xamarin Forms and bring the map. I have given Android UI xml and activity file for sample.



     <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.phunware.java.sample.LoadBuildingActivity">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:name="com.phunware.mapping.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignTop="@id/map"
    android:background="@color/white"
    android:orientation="vertical"
    android:padding="6dp">

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/switch_floors" />

    <Spinner
    android:id="@+id/floorSpinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
    </LinearLayout>

    </RelativeLayout>

    package com.landt.ismartphunware2;

    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.util.Log;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.Spinner;

    import com.google.android.gms.maps.CameraUpdate;
    import com.google.android.gms.maps.CameraUpdateFactory;
    import com.phunware.core.PwCoreSession;
    //import com.phunware.java.sample.R;
    import com.phunware.mapping.MapFragment;
    import com.phunware.mapping.OnPhunwareMapReadyCallback;
    import com.phunware.mapping.PhunwareMap;
    import com.phunware.mapping.manager.Callback;
    import com.phunware.mapping.manager.PhunwareMapManager;
    import com.phunware.mapping.model.Building;
    import com.phunware.mapping.model.FloorOptions;

    public class LoadBuildingActivity extends AppCompatActivity implements OnPhunwareMapReadyCallback
    private static final String TAG = LoadBuildingActivity.class.getSimpleName();
    private PhunwareMapManager mapManager;
    private Building currentBuilding;
    private ArrayAdapter<FloorOptions> spinnerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    setContentView(R.layout.load_building);

    Spinner floorSpinner = findViewById(R.id.floorSpinner);
    spinnerAdapter = new FloorAdapter(this);
    floorSpinner.setAdapter(spinnerAdapter);
    floorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
    FloorOptions floor = spinnerAdapter.getItem((int) id);
    if (currentBuilding != null && floor != null)
    currentBuilding.selectFloor(floor.getLevel());



    @Override
    public void onNothingSelected(AdapterView<?> parent)

    );

    // Create the map manager used to load the building
    mapManager = PhunwareMapManager.create(this);

    // Register the Phunware API keys
    PwCoreSession.getInstance().registerKeys(this);

    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    if (mapFragment != null)
    mapFragment.getPhunwareMapAsync(this);



    @Override
    public void onPhunwareMapReady(final PhunwareMap phunwareMap)
    // Retrieve buildingId from integers.xml
    int buildingId = getResources().getInteger(R.integer.buildingId);

    mapManager.setPhunwareMap(phunwareMap);
    mapManager.addBuilding(buildingId,
    new Callback<Building>()
    @Override
    public void onSuccess(Building building)
    Log.d(TAG, "Building loaded successfully");
    currentBuilding = building;

    // Populate floor spinner
    spinnerAdapter.clear();
    spinnerAdapter.addAll(building.getBuildingOptions().getFloors());

    // Set building to initial floor value
    FloorOptions initialFloor = building.initialFloor();
    building.selectFloor(initialFloor.getLevel());

    // Animate the camera to the building at an appropriate zoom level
    CameraUpdate cameraUpdate = CameraUpdateFactory
    .newLatLngBounds(initialFloor.getBounds(), 4);
    phunwareMap.getGoogleMap().animateCamera(cameraUpdate);


    @Override
    public void onFailure(Throwable throwable)
    Log.d(TAG, "Error when loading building -- " + throwable.getMessage());

    );




    Here, they are casting UI control to MapFragment and calling getPhunwareMapAsync() method. I just want to know in Xamarin Forms what control we can map to this MapFragment? In case we are about to write equivalent code in MainActivity of Xamarin Android project, how can we establish connection between PCL project and Android project and bring the map in View? I am just trying to figure out how to start and what to put where as I have excellent experience in Xamarin Forms but less experience with Android Native.










    share|improve this question
























      0












      0








      0







      I am planning to integrate Phunware map within Xamarin Forms app. I am able to create Android Binding project so I can get packages equivalent to Phunware Android native SDK. By this I am able to access all methods and classes of Phunware SDK. Now the challenge is I have to follow Phunware Android native sample app source code, write equivalent code in Xamarin Forms and bring the map. I have given Android UI xml and activity file for sample.



       <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.phunware.java.sample.LoadBuildingActivity">

      <fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:name="com.phunware.mapping.MapFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

      <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignTop="@id/map"
      android:background="@color/white"
      android:orientation="vertical"
      android:padding="6dp">

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/switch_floors" />

      <Spinner
      android:id="@+id/floorSpinner"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
      </LinearLayout>

      </RelativeLayout>

      package com.landt.ismartphunware2;

      import android.os.Bundle;
      import android.support.v7.app.AppCompatActivity;
      import android.util.Log;
      import android.view.View;
      import android.widget.AdapterView;
      import android.widget.ArrayAdapter;
      import android.widget.Spinner;

      import com.google.android.gms.maps.CameraUpdate;
      import com.google.android.gms.maps.CameraUpdateFactory;
      import com.phunware.core.PwCoreSession;
      //import com.phunware.java.sample.R;
      import com.phunware.mapping.MapFragment;
      import com.phunware.mapping.OnPhunwareMapReadyCallback;
      import com.phunware.mapping.PhunwareMap;
      import com.phunware.mapping.manager.Callback;
      import com.phunware.mapping.manager.PhunwareMapManager;
      import com.phunware.mapping.model.Building;
      import com.phunware.mapping.model.FloorOptions;

      public class LoadBuildingActivity extends AppCompatActivity implements OnPhunwareMapReadyCallback
      private static final String TAG = LoadBuildingActivity.class.getSimpleName();
      private PhunwareMapManager mapManager;
      private Building currentBuilding;
      private ArrayAdapter<FloorOptions> spinnerAdapter;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.load_building);

      Spinner floorSpinner = findViewById(R.id.floorSpinner);
      spinnerAdapter = new FloorAdapter(this);
      floorSpinner.setAdapter(spinnerAdapter);
      floorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
      @Override
      public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
      FloorOptions floor = spinnerAdapter.getItem((int) id);
      if (currentBuilding != null && floor != null)
      currentBuilding.selectFloor(floor.getLevel());



      @Override
      public void onNothingSelected(AdapterView<?> parent)

      );

      // Create the map manager used to load the building
      mapManager = PhunwareMapManager.create(this);

      // Register the Phunware API keys
      PwCoreSession.getInstance().registerKeys(this);

      MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
      if (mapFragment != null)
      mapFragment.getPhunwareMapAsync(this);



      @Override
      public void onPhunwareMapReady(final PhunwareMap phunwareMap)
      // Retrieve buildingId from integers.xml
      int buildingId = getResources().getInteger(R.integer.buildingId);

      mapManager.setPhunwareMap(phunwareMap);
      mapManager.addBuilding(buildingId,
      new Callback<Building>()
      @Override
      public void onSuccess(Building building)
      Log.d(TAG, "Building loaded successfully");
      currentBuilding = building;

      // Populate floor spinner
      spinnerAdapter.clear();
      spinnerAdapter.addAll(building.getBuildingOptions().getFloors());

      // Set building to initial floor value
      FloorOptions initialFloor = building.initialFloor();
      building.selectFloor(initialFloor.getLevel());

      // Animate the camera to the building at an appropriate zoom level
      CameraUpdate cameraUpdate = CameraUpdateFactory
      .newLatLngBounds(initialFloor.getBounds(), 4);
      phunwareMap.getGoogleMap().animateCamera(cameraUpdate);


      @Override
      public void onFailure(Throwable throwable)
      Log.d(TAG, "Error when loading building -- " + throwable.getMessage());

      );




      Here, they are casting UI control to MapFragment and calling getPhunwareMapAsync() method. I just want to know in Xamarin Forms what control we can map to this MapFragment? In case we are about to write equivalent code in MainActivity of Xamarin Android project, how can we establish connection between PCL project and Android project and bring the map in View? I am just trying to figure out how to start and what to put where as I have excellent experience in Xamarin Forms but less experience with Android Native.










      share|improve this question













      I am planning to integrate Phunware map within Xamarin Forms app. I am able to create Android Binding project so I can get packages equivalent to Phunware Android native SDK. By this I am able to access all methods and classes of Phunware SDK. Now the challenge is I have to follow Phunware Android native sample app source code, write equivalent code in Xamarin Forms and bring the map. I have given Android UI xml and activity file for sample.



       <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.phunware.java.sample.LoadBuildingActivity">

      <fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:name="com.phunware.mapping.MapFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

      <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignTop="@id/map"
      android:background="@color/white"
      android:orientation="vertical"
      android:padding="6dp">

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/switch_floors" />

      <Spinner
      android:id="@+id/floorSpinner"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
      </LinearLayout>

      </RelativeLayout>

      package com.landt.ismartphunware2;

      import android.os.Bundle;
      import android.support.v7.app.AppCompatActivity;
      import android.util.Log;
      import android.view.View;
      import android.widget.AdapterView;
      import android.widget.ArrayAdapter;
      import android.widget.Spinner;

      import com.google.android.gms.maps.CameraUpdate;
      import com.google.android.gms.maps.CameraUpdateFactory;
      import com.phunware.core.PwCoreSession;
      //import com.phunware.java.sample.R;
      import com.phunware.mapping.MapFragment;
      import com.phunware.mapping.OnPhunwareMapReadyCallback;
      import com.phunware.mapping.PhunwareMap;
      import com.phunware.mapping.manager.Callback;
      import com.phunware.mapping.manager.PhunwareMapManager;
      import com.phunware.mapping.model.Building;
      import com.phunware.mapping.model.FloorOptions;

      public class LoadBuildingActivity extends AppCompatActivity implements OnPhunwareMapReadyCallback
      private static final String TAG = LoadBuildingActivity.class.getSimpleName();
      private PhunwareMapManager mapManager;
      private Building currentBuilding;
      private ArrayAdapter<FloorOptions> spinnerAdapter;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.load_building);

      Spinner floorSpinner = findViewById(R.id.floorSpinner);
      spinnerAdapter = new FloorAdapter(this);
      floorSpinner.setAdapter(spinnerAdapter);
      floorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
      @Override
      public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
      FloorOptions floor = spinnerAdapter.getItem((int) id);
      if (currentBuilding != null && floor != null)
      currentBuilding.selectFloor(floor.getLevel());



      @Override
      public void onNothingSelected(AdapterView<?> parent)

      );

      // Create the map manager used to load the building
      mapManager = PhunwareMapManager.create(this);

      // Register the Phunware API keys
      PwCoreSession.getInstance().registerKeys(this);

      MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
      if (mapFragment != null)
      mapFragment.getPhunwareMapAsync(this);



      @Override
      public void onPhunwareMapReady(final PhunwareMap phunwareMap)
      // Retrieve buildingId from integers.xml
      int buildingId = getResources().getInteger(R.integer.buildingId);

      mapManager.setPhunwareMap(phunwareMap);
      mapManager.addBuilding(buildingId,
      new Callback<Building>()
      @Override
      public void onSuccess(Building building)
      Log.d(TAG, "Building loaded successfully");
      currentBuilding = building;

      // Populate floor spinner
      spinnerAdapter.clear();
      spinnerAdapter.addAll(building.getBuildingOptions().getFloors());

      // Set building to initial floor value
      FloorOptions initialFloor = building.initialFloor();
      building.selectFloor(initialFloor.getLevel());

      // Animate the camera to the building at an appropriate zoom level
      CameraUpdate cameraUpdate = CameraUpdateFactory
      .newLatLngBounds(initialFloor.getBounds(), 4);
      phunwareMap.getGoogleMap().animateCamera(cameraUpdate);


      @Override
      public void onFailure(Throwable throwable)
      Log.d(TAG, "Error when loading building -- " + throwable.getMessage());

      );




      Here, they are casting UI control to MapFragment and calling getPhunwareMapAsync() method. I just want to know in Xamarin Forms what control we can map to this MapFragment? In case we are about to write equivalent code in MainActivity of Xamarin Android project, how can we establish connection between PCL project and Android project and bring the map in View? I am just trying to figure out how to start and what to put where as I have excellent experience in Xamarin Forms but less experience with Android Native.







      android xamarin.forms binding






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 9:12









      RameshRamesh

      91211026




      91211026






















          1 Answer
          1






          active

          oldest

          votes


















          2














          Suggetion 1:



          You could try using Xamarin.Forms.Maps:




          Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, to provide a fast and familiar map experience for users.





          • Xamarin.Forms Map

            • Basic usage about Xamarin.Forms.Map

            • Map functionality can be further enhanced by creating a map custom renderer.



          • Customizing a Xamarin.Forms Map

            • This article explains how to create a custom renderer for the Map control, which displays a native map with a customized pin and a customized view of the pin data on each platform.


          Suggestion 2:



          Customizing a ContentPage to display the Android native page that had a map along with some other controls:




          A ContentPage is a visual element that displays a single view and occupies most of the screen. This article demonstrates how to create a custom renderer for the ContentPage page, enabling developers to override the default native rendering with their own platform-specific customization.





          • Xamarin.Forms: Displaying a Native Android Page



            • In this case, it will display a content page that had a map along with some other controls. It demonstrate how to load a native android page within a Xamarin.Forms app.


          • Customizing a ContentPage


          • Customize Your Xamarin.Forms App With Pages For Each Platform





          share|improve this answer




















          • Thank you. I am about to follow suggestion 2
            – Ramesh
            Nov 15 '18 at 6:53










          • PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
            – Ramesh
            Nov 15 '18 at 7:24






          • 1




            @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
            – York Shen - MSFT
            Nov 15 '18 at 7:30










          • Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
            – Ramesh
            Nov 15 '18 at 12:12











          • @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
            – York Shen - MSFT
            Nov 16 '18 at 1:35










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277481%2fhow-to-render-ui-controls-in-xamarin-forms-equivalent-to-android-native-controls%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Suggetion 1:



          You could try using Xamarin.Forms.Maps:




          Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, to provide a fast and familiar map experience for users.





          • Xamarin.Forms Map

            • Basic usage about Xamarin.Forms.Map

            • Map functionality can be further enhanced by creating a map custom renderer.



          • Customizing a Xamarin.Forms Map

            • This article explains how to create a custom renderer for the Map control, which displays a native map with a customized pin and a customized view of the pin data on each platform.


          Suggestion 2:



          Customizing a ContentPage to display the Android native page that had a map along with some other controls:




          A ContentPage is a visual element that displays a single view and occupies most of the screen. This article demonstrates how to create a custom renderer for the ContentPage page, enabling developers to override the default native rendering with their own platform-specific customization.





          • Xamarin.Forms: Displaying a Native Android Page



            • In this case, it will display a content page that had a map along with some other controls. It demonstrate how to load a native android page within a Xamarin.Forms app.


          • Customizing a ContentPage


          • Customize Your Xamarin.Forms App With Pages For Each Platform





          share|improve this answer




















          • Thank you. I am about to follow suggestion 2
            – Ramesh
            Nov 15 '18 at 6:53










          • PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
            – Ramesh
            Nov 15 '18 at 7:24






          • 1




            @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
            – York Shen - MSFT
            Nov 15 '18 at 7:30










          • Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
            – Ramesh
            Nov 15 '18 at 12:12











          • @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
            – York Shen - MSFT
            Nov 16 '18 at 1:35















          2














          Suggetion 1:



          You could try using Xamarin.Forms.Maps:




          Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, to provide a fast and familiar map experience for users.





          • Xamarin.Forms Map

            • Basic usage about Xamarin.Forms.Map

            • Map functionality can be further enhanced by creating a map custom renderer.



          • Customizing a Xamarin.Forms Map

            • This article explains how to create a custom renderer for the Map control, which displays a native map with a customized pin and a customized view of the pin data on each platform.


          Suggestion 2:



          Customizing a ContentPage to display the Android native page that had a map along with some other controls:




          A ContentPage is a visual element that displays a single view and occupies most of the screen. This article demonstrates how to create a custom renderer for the ContentPage page, enabling developers to override the default native rendering with their own platform-specific customization.





          • Xamarin.Forms: Displaying a Native Android Page



            • In this case, it will display a content page that had a map along with some other controls. It demonstrate how to load a native android page within a Xamarin.Forms app.


          • Customizing a ContentPage


          • Customize Your Xamarin.Forms App With Pages For Each Platform





          share|improve this answer




















          • Thank you. I am about to follow suggestion 2
            – Ramesh
            Nov 15 '18 at 6:53










          • PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
            – Ramesh
            Nov 15 '18 at 7:24






          • 1




            @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
            – York Shen - MSFT
            Nov 15 '18 at 7:30










          • Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
            – Ramesh
            Nov 15 '18 at 12:12











          • @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
            – York Shen - MSFT
            Nov 16 '18 at 1:35













          2












          2








          2






          Suggetion 1:



          You could try using Xamarin.Forms.Maps:




          Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, to provide a fast and familiar map experience for users.





          • Xamarin.Forms Map

            • Basic usage about Xamarin.Forms.Map

            • Map functionality can be further enhanced by creating a map custom renderer.



          • Customizing a Xamarin.Forms Map

            • This article explains how to create a custom renderer for the Map control, which displays a native map with a customized pin and a customized view of the pin data on each platform.


          Suggestion 2:



          Customizing a ContentPage to display the Android native page that had a map along with some other controls:




          A ContentPage is a visual element that displays a single view and occupies most of the screen. This article demonstrates how to create a custom renderer for the ContentPage page, enabling developers to override the default native rendering with their own platform-specific customization.





          • Xamarin.Forms: Displaying a Native Android Page



            • In this case, it will display a content page that had a map along with some other controls. It demonstrate how to load a native android page within a Xamarin.Forms app.


          • Customizing a ContentPage


          • Customize Your Xamarin.Forms App With Pages For Each Platform





          share|improve this answer












          Suggetion 1:



          You could try using Xamarin.Forms.Maps:




          Xamarin.Forms.Maps provides a cross-platform abstraction for displaying maps that use the native map APIs on each platform, to provide a fast and familiar map experience for users.





          • Xamarin.Forms Map

            • Basic usage about Xamarin.Forms.Map

            • Map functionality can be further enhanced by creating a map custom renderer.



          • Customizing a Xamarin.Forms Map

            • This article explains how to create a custom renderer for the Map control, which displays a native map with a customized pin and a customized view of the pin data on each platform.


          Suggestion 2:



          Customizing a ContentPage to display the Android native page that had a map along with some other controls:




          A ContentPage is a visual element that displays a single view and occupies most of the screen. This article demonstrates how to create a custom renderer for the ContentPage page, enabling developers to override the default native rendering with their own platform-specific customization.





          • Xamarin.Forms: Displaying a Native Android Page



            • In this case, it will display a content page that had a map along with some other controls. It demonstrate how to load a native android page within a Xamarin.Forms app.


          • Customizing a ContentPage


          • Customize Your Xamarin.Forms App With Pages For Each Platform






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 5:49









          York Shen - MSFTYork Shen - MSFT

          6,7661325




          6,7661325











          • Thank you. I am about to follow suggestion 2
            – Ramesh
            Nov 15 '18 at 6:53










          • PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
            – Ramesh
            Nov 15 '18 at 7:24






          • 1




            @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
            – York Shen - MSFT
            Nov 15 '18 at 7:30










          • Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
            – Ramesh
            Nov 15 '18 at 12:12











          • @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
            – York Shen - MSFT
            Nov 16 '18 at 1:35
















          • Thank you. I am about to follow suggestion 2
            – Ramesh
            Nov 15 '18 at 6:53










          • PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
            – Ramesh
            Nov 15 '18 at 7:24






          • 1




            @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
            – York Shen - MSFT
            Nov 15 '18 at 7:30










          • Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
            – Ramesh
            Nov 15 '18 at 12:12











          • @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
            – York Shen - MSFT
            Nov 16 '18 at 1:35















          Thank you. I am about to follow suggestion 2
          – Ramesh
          Nov 15 '18 at 6:53




          Thank you. I am about to follow suggestion 2
          – Ramesh
          Nov 15 '18 at 6:53












          PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
          – Ramesh
          Nov 15 '18 at 7:24




          PhunwareMapManager.create(this); This method takes Context as argument. I am not sure how it should be done in Xamarin Android MainActivity. Can you help how to get the context in activity class and pass to this method?
          – Ramesh
          Nov 15 '18 at 7:24




          1




          1




          @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
          – York Shen - MSFT
          Nov 15 '18 at 7:30




          @Ramesh, you could install CurrentActivityPlugin, then, you can call CrossCurrentActivity.Current.Activity when you need to access the current activity: Context CurrentContext => CrossCurrentActivity.Current.Activity.
          – York Shen - MSFT
          Nov 15 '18 at 7:30












          Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
          – Ramesh
          Nov 15 '18 at 12:12





          Shen, excellent. It works. Also, I am able to bind classes, interfaces and methods in metadata.xml for Android. Can you please guide me how to do binding in metadata.xml for generic classes, for example Callback<Building> classes as in above code. If I am able to bind this generic class I will be able to complete the bindings and bring the map in Xamarin app. I am asking you because I am unable to find reference/help on and off internet on this.
          – Ramesh
          Nov 15 '18 at 12:12













          @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
          – York Shen - MSFT
          Nov 16 '18 at 1:35




          @Ramesh, you could create a new question and post more detailed information about it, I will be there to help u.
          – York Shen - MSFT
          Nov 16 '18 at 1:35

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277481%2fhow-to-render-ui-controls-in-xamarin-forms-equivalent-to-android-native-controls%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線