【发布时间】:2019-12-18 11:44:51
【问题描述】:
我想选择 ListView 中的一项,然后按编辑按钮,该按钮对选定的 Listview 项进行处理。但是只要我从列表视图中移动鼠标,选择就会消失。 (我在VS模拟器上测试) 我确实在 Internet 上查找了示例,但它们使用了根本不存在的不同属性。
这里是axml的部分代码:
<TableLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout4">
<TableRow>
<TextView
android:text="Ingredients List :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView1" />
<Button
android:text="Edit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/editIngerientsButton" />
</TableRow>
<TableRow>
<ListView
android:minWidth="25px"
android:minHeight="50px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ingredientsListView"
android:layout_span="2"
android:choiceMode="singleChoice" />
</TableRow>
</TableLayout>
这里是代码
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.parsing_recepie);
ingredientsListView = (ListView) FindViewById(Resource.Id.ingredientsListView);
ingredients = new List<Ingredient>();
arrayAdapter = new ArrayAdapter<Ingredient>(this,
Android.Resource.Layout.SimpleListItem1, ingredients);
ingredientsListView.Adapter = arrayAdapter;
ingredientsListView.ChoiceMode = ChoiceMode.Single;
editIngredientsButton = (Button) FindViewById(Resource.Id.editIngerientsButton);
editIngredientsButton.Click += EditIngredientsButtonOnClick;
}
【问题讨论】:
标签: c# listview select xamarin.android