Xamarin Android 下拉列表

<Spinner android:id="@+id/spinner"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
Spinner spinner = FindViewById(Resource.Id.spinner);
            var adapter = ArrayAdapter.CreateFromResource(
                    this, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = adapter;
<string-array name="planets_array">
      <item>Mercuryitem>
      <item>Venusitem>
      <item>Earthitem>
      <item>Marsitem>
      <item>Jupiteritem>
      <item>Saturnitem>
      <item>Uranusitem>
      <item>Neptuneitem>
    string-array>

 

转载于:https://www.cnblogs.com/nanfei/p/7977582.html

你可能感兴趣的:(Xamarin Android 下拉列表)