C# ListView项单击单机器人

C# ListView项单击单机器人,c#,android,xamarin.android,C#,Android,Xamarin.android,我有一个自动完成的文本视图,一个带有文本视图的列表视图。我想将选中的文本项发送到Toast语句。下面是我的代码,后面是main.xaml和item_list.xml String[] names = GetAllNames(db1.WritableDatabase); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, Resource.Layout.list_item,

我有一个自动完成的文本视图,一个带有文本视图的列表视图。我想将选中的文本项发送到Toast语句。下面是我的代码,后面是main.xaml和item_list.xml

       String[] names = GetAllNames(db1.WritableDatabase);
       ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, Resource.Layout.list_item, names);
       textView.Adapter = adapter;


     ListView input1 = (ListView)FindViewById(Resource.Id.lview1);

       input1.ItemClick += delegate(object sender, ItemEventArgs args)
       {
        // When clicked, show a toast with the TextView text  
      Toast.MakeText(Application, ((TextView)args.View).Text, ToastLength.Short).Show();
       };  

   /*   main.xaml */

   <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <Button
  android:id="@+id/MyButton"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/Hello"/>
  <AutoCompleteTextView android:id="@+id/autocompleteName"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginLeft="5dp"/>
   <ListView
     android:id="@+id/lview1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content">
   </ListView>
   </LinearLayout>

  /* list_item.xml */

  <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/tview1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="test"
  android:textSize="20sp"
  >
  </TextView>
当我从列表中选择填充AutoCompleteText框时,我没有看到选择


提前谢谢

我知道这篇文章已经很老了,但我想你应该改用AutoCompleteTextView.ItemClick。此外,您不需要ListView,因为文本视图有自己的列表可供选择