简体   繁体   English

可搜索的Dropdown Spinner xamarin Android

[英]Searchable Dropdown spinner xamarin Android

Searchable Dropdown spinner hi ,, I have spinner full by sqlite database I want can search in it how can i do that I try used Autocomplete text but not worked well this my spinner.aXml 可搜索的Dropdown Spinner嗨,,我有sqlite数据库完整的Spinner,我想可以在其中搜索如何操作我尝试使用自动完成文本,但是在我的spinner.aXml中效果不佳

 <Spinner
       android:layout_width="match_parent"
        android:layout_height="35dp"
        android:id="@+id/SpinnerHotel"
        android:paddingLeft="10dp"
        android:background="@drawable/Spinner_Style"
        android:spinnerMode="dropdown"
        android:gravity="center"
        android:visibility="visible"
        android:layout_marginRight="10dp"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="15dp" />


 and text_View.axml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="20dp"
                      android:id="@+id/autoCompleteTextView1" 
    android:textColor="#68767A"
    android:text="Select a Hotel .. "
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:textSize="18dp" />

and this my Activity 这是我的活动

  async    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.GoShow_layout);

        Agent = FindViewById<Spinner>(Resource.Id.SpinnerAgentt);

        List<string> my_array = new List<string>();
          my_array = await login.Get_Hotel();
        ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Resource.Layout.Text_View, my_array);
        adapter.SetDropDownViewResource(Resource.Layout.Text_View);
        Hotel.Adapter = adapter;
        Hotel.ItemSelected += Hotel_ItemSelected;




    }

private void Agent_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
    var Spinner = sender as Spinner;
    string Agentt = Spinner.GetItemAtPosition(e.Position).ToString();

    Toast.MakeText(this, Agentt , ToastLength.Short).Show();
} 

我认为您必须将Spinner与AutoCompleteTextView结合使用,例如在此处将Spinner和AutoCompleteTextView 结合使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM