Xamarin.Android | ComponentOne
Controls / Gauge / Quick Start: Add and Configure / BulletGraph Quick Start
In This Topic
    BulletGraph Quick Start
    In This Topic

    This section describes how to add a C1BulletGraph control to android application and set some of its properties.

    This topic comprises of three steps:

    The following image shows how the C1BulletGraph appears, after completing the steps above.

    customized bullet graph

    Step 1: Add a C1BulletGraph control

    Complete the following steps to initialize a C1BulletGraph control.

    In Code

    1. Add the following reference in the MainActivity class file.
      C#
      Copy Code
      using C1.Android.Gauge;
    2. Instantiate a C1BulletGraph control in the MainActivity class and set some of its properties as follows.
      C#
      Copy Code
      using Android.App;
      using Android.Widget;
      using Android.OS;
      using C1.Android.Gauge;
      
      namespace AndroidGauge
      {
          [Activity(Label = "AndroidGauge", MainLauncher = true)]
          public class MainActivity : Activity
          { 
          private C1BulletGraph mBulletGraph;
          private int mValue = 25;
          private int mMin = 0;
          private int mMax = 100;
              protected override void OnCreate(Bundle bundle)
              {
                  base.OnCreate(bundle);
                  mBulletGraph = (C1BulletGraph)FindViewById(Resource.Id.c1BulletGraph1);
                  mBulletGraph.Enabled = true;
                  mBulletGraph.Value = mValue;
                  mBulletGraph.Min = mMin;
                  mBulletGraph.Max = mMax;
                  mBulletGraph.Step = 1;
                  mBulletGraph.ShowText = GaugeShowText.All;
                  mBulletGraph.IsReadOnly = false;
                  mBulletGraph.IsAnimated = true;
                  // Set our view from the "main" layout resource
                  SetContentView(Resource.Layout.Main);
              }
          }
      }
    3. Add the following XML code in Main.axml in case of C#, to render the control onto the device.
      C#
      Copy Code
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
      android:layout_width="fill_parent"    
      android:layout_height="fill_parent"    
      android:orientation="vertical"    
      android:paddingLeft="16dp"    
      android:paddingRight="16dp"
      android:layout_width="wrap_content"      
      android:layout_height="wrap_content"      
      android:text="bullet graph"
      android:id="@+id/bulletgraph"      
      android:layout_width="match_parent"      
      android:layout_height="50dp" />
      
      </LinearLayout>

    Step 2: Run the Project

    In the ToolBar section, select the Android device and then press F5 to view the output.

    Back to Top
    See Also