カラーバンドから抵抗値を計算するアプリを作成しています。純粋なプログラミング側では、すべてが正常に機能します。現時点では、色のバンドを選択するために、色のリストで満たされたスピナーを使用しています。
どうしても見栄えを良くしたい。スピナーの各アイテムの背景色を対応する色に設定できるようにしたい:
これを達成するにはどうすればよいですか?ここに私のコードの一部があります:
スピナーに使用される配列:
<string-array name="FourBandResistorFullColor">
<item>Black</item>
<item>Brown</item>
<item>Red</item>
<item>Orange</item>
<item>Yellow</item>
<item>Green</item>
<item>Blue</item>
<item>Violet</item>
<item>Gray</item>
<item>White</item>
</string-array>
メソッド内のアダプタ コードOnCreate
:
var bandOne = FindViewById<Spinner>(Resource.Id.bandOneColor);
var bandOneAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.FourBandResistorFullColor,
Android.Resource.Layout.SimpleSpinnerItem);
bandOneAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
bandOne.Adapter = bandOneAdapter;
bandOne.ItemSelected += BandOne_ItemSelected;