[android] #4365 - add toolbar to Polygon example
This commit is contained in:
@@ -2,7 +2,11 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
@@ -24,6 +28,16 @@ public class PolygonActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_polygon);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
// configure inital map state
|
||||
MapboxMapOptions options = new MapboxMapOptions()
|
||||
@@ -61,8 +75,8 @@ public class PolygonActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
// set as content view
|
||||
setContentView(mapView);
|
||||
// add to layout
|
||||
((ViewGroup) findViewById(R.id.container)).addView(mapView);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,4 +108,15 @@ public class PolygonActivity extends AppCompatActivity {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/primary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -3,5 +3,7 @@
|
||||
<item name="mapView" type="id" />
|
||||
<item name="fab" type="id" />
|
||||
<item name="imageView" type="id" />
|
||||
<item name="toolbar" type="id" />
|
||||
<item name="container" type="id" />
|
||||
<item name="item_click_support" type="id" />
|
||||
</resources>
|
||||
Reference in New Issue
Block a user