Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Android

Classbreaks Renderer

The ClassBreaksRenderer sample is an app to demonstrate rendering using class breaks. The sample depends on the feature layer to be running:

How to use the Sample

This sample uses GeodatabaseFeatureServiceTable to display the FeatureLayer. Class breaks are created and added to the layer. Wind stations are displayed using arrow markers whose size depends upon the wind speeds and rotation depends on the wind direction.

App usage

  1. The feature layer might take a few seconds to load. Otherwise check if the service is running.
  2. Once the layer is loaded, click on an arrow marker.
  3. A callout is displayed showing the Station Name, Country, Temperature and Wind Speed.

Sample Code

/* Copyright 2014 ESRI
 * All rights reserved under the copyright laws of the United States
 * and applicable international laws, treaties, and conventions.
 * You may freely redistribute and use this sample code, with or
 * without modification, provided you include the original copyright
 * notice and use restrictions.
 * See the Sample code usage restrictions document for further information.


import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.esri.core.geodatabase.GeodatabaseFeatureServiceTable;
import com.esri.core.geodatabase.GeodatabaseFeatureServiceTable.Status;
import com.esri.core.geometry.Point;
import com.esri.core.renderer.ClassBreaksRenderer;

 * This app uses GeodatabaseFeatureServiceTable and Feature Layer. It
 * demonstrates the use of Class breaks renderer. Wind stations are displayed
 * using arrow markers whose size depends upon the wind speeds and rotation
 * depends on the wind direction. On clicking an arrow marker, a callout is
 * displayed which shows the station name, country, temperature and wind speed.
 * Please be aware that the Feature Layer service is not guaranteed to be
 * running.

public class ClassBreaksRendererActivity extends Activity {

	MapView mMapView;
	GeodatabaseFeatureServiceTable table;
	FeatureLayer feature_layer;
	ClassBreaksRenderer wind_renderer;
	static int LAYER_ID = 0;
	View calloutView;

	/** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) {


		mMapView = (MapView) findViewById(;

		// Inflate the view for the callouts
		calloutView = View.inflate(this, R.xml.callout, null);

		String url = this.getResources().getString(R.string.featurelayer_url);

		// Create the GeodatabaseFeatureServiceTable from service url and layer
		// id
		table = new GeodatabaseFeatureServiceTable(url, LAYER_ID);
		// Initializing the GeodatabaseFeatureServiceTable asynchronously
		table.initialize(new CallbackListener<GeodatabaseFeatureServiceTable.Status>() {

			public void onCallback(Status objs) {
				if (objs == Status.INITIALIZED) {

					// Creating a feature table
					feature_layer = new FeatureLayer(table);
					// Adding feature layer to the map

			public void onError(Throwable e) {
				// Get the error using getInitializationError() method
				Toast.makeText(getApplicationContext(), "Feature Layer not available", Toast.LENGTH_LONG).show();

		// Identify on single tap of map
		mMapView.setOnSingleTapListener(new OnSingleTapListener() {

			private static final long serialVersionUID = 1L;

			public void onSingleTap(final float x, final float y) {

				// Check if there is a feature present
				if (feature_layer.getFeatureIDs(x, y, 20).length != 0) {

					Point mapPoint = mMapView.toMapPoint(x, y);

					long[] iDs = feature_layer.getFeatureIDs(x, y, 20);

					// Get the particular feature values and highlight it
					Feature f = feature_layer.getFeature(iDs[0]);
					String station_name = (String) f
					String country_name = (String) f
					String temp = (String) f.getAttributeValue("TEMP")
					String wind_speed = (String) f.getAttributeValue(

					// Update the content of the callout
					updateContent(station_name, country_name, temp, wind_speed);
					// Create callout from mapview
					Callout mapCallout = mMapView.getCallout();
					// populate callout with updated content
					mapCallout.setOffset(0,  -3);
					// show callout;



	 * Updating the content of the callout with the feature values

	private void updateContent(String station, String country, String temp,
			String wind_speed) {

		if (calloutView == null)

		TextView tv_station = (TextView) calloutView.findViewById(;

		TextView tv_country = (TextView) calloutView.findViewById(;

		TextView tv_temp = (TextView) calloutView.findViewById(;
		tv_temp.setText(temp + "F");

		TextView tv_speed = (TextView) calloutView.findViewById(;


	 * Called when the activity is destroyed

	protected void onDestroy() {


	 * Called when the activity pauses

	protected void onPause() {



	 * Called when the activity resumes

	protected void onResume() {



Feedback on this topic?