Xuni コントロール > Gauge > クイックスタート:追加と設定 > BulletGraph クイックスタート |
このセクションでは、XuniBulletGraph コントロールを Android アプリケーションに追加し、いくつかのプロパティを設定する方法について説明します。Java で Xuni コンポーネントを追加する方法については、「Java による Xuni コンポーネントの追加」を参照してください。
このトピックは 3 つの手順で構成されます。
次の図は、上記の手順を実行した後の XuniBulletGraph を示しています。
XuniBulletGraph コントロールを初期化するには、次の手順を実行します。
Java |
コードのコピー
|
---|---|
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); XuniBulletGraph gauge = (XuniBulletGraph)findViewById(R.id.gauge); //基本的なプロパティの設定 gauge.setMax(100); gauge.setMin(0); gauge.setValue(50); gauge.setGaugeWidth(.3f); //Good、Bad、および Target を設定します gauge.setGood(75); gauge.setGoodRangeColor(Color.GRAY); gauge.setBad(40); gauge.setBadRangeColor(Color.DKGRAY); gauge.setTarget(80); gauge.setTargetRangeColor(Color.BLACK); } } |
C# |
コードのコピー
|
---|---|
public class MainActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // 「メイン」レイアウトリソースからビューを設定します SetContentView(Resource.Layout.Main); XuniBulletGraph bulletGraph = FindViewById<XuniBulletGraph>(Resource.Id.bulletgraph); bulletGraph.Pointer.Width = 0.5f; bulletGraph.Min = 0; bulletGraph.Max = 100; bulletGraph.Value = 50; //Good、Bad、および Target を設定します bulletGraph.Target = 80; bulletGraph.Good = 75; bulletGraph.Bad = 40; } } |
XML |
コードのコピー
|
---|---|
<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.gaugeeclipse.MainActivity" > <com.grapecity.xuni.gauge.XuniBulletGraph android:layout_width="match_parent" android:layout_height="100dp" android:id="@+id/gauge" > </com.grapecity.xuni.gauge.XuniBulletGraph> </RelativeLayout> |
C# |
コードのコピー
|
---|---|
<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"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bullet graph" /> <com.grapecity.xuni.gauge.XuniBulletGraph android:id="@+id/bulletgraph" android:layout_width="match_parent" android:layout_height="50dp" /> </LinearLayout> |
パッケージエクスプローラーで、アプリケーションを右クリックし、[実行]→[Android アプリケーション]をクリックします。
先頭に戻る