可搜索的下拉旋转器 嗨,我有spinner完全由sqlite数据库我希望可以搜索它 我怎样才能做到这一点 我尝试使用自动填充文本,但效果不佳 这是我的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" />
这是我的活动
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();
}
答案 0 :(得分:0)
我认为你必须将Spinner与AutoCompleteTextView结合起来,就像这里Combine Spinner and AutoCompleteTextView
一样