Xamarin - AutoComplete出现在错误的位置

时间:2017-01-03 12:10:52

标签: xamarin xamarin.android recycler-adapter

我在recyclerAdapter中使用自动完成功能

这是我的代码

viewHolder.itemName.AfterTextChanged += ItemName_AfterTextChanged;

...
..
.


private void ItemName_AfterTextChanged(object sender, AfterTextChangedEventArgs e)
        {
            ExtAutoCompleteTextView autoCompleteItemName = (ExtAutoCompleteTextView)sender;
            int position = int.Parse(autoCompleteItemName.Tag.ToString());
            autoCompleteItemName.AfterTextChanged -= ItemName_AfterTextChanged;
            HandleAutoComplete(position);
            autoCompleteItemName.AfterTextChanged += ItemName_AfterTextChanged;
        }


private void HandleAutoComplete(int position)
        {

            // check position is correct
            ItemCustomViewHolder PassViewHolder = FindViewHolderByPoistion(position);
             matchedItems = itemDAL.GetMatchedName(PassViewHolder.itemName.Text);
                CustomAdapter arrayAdapter = new CustomAdapter(mContext, Android.Resource.Layout.SimpleListItem1, matchedItems.Select(c => c.TradeNameEn).ToList());
                PassViewHolder.itemName.Adapter = arrayAdapter;

        }

public ItemCustomViewHolder FindViewHolderByPoistion(object tag)
        {
            int pos; 
            int.TryParse(tag.ToString() , out pos);

            //View child = recyclerView.GetChildAt(pos );   
                return (mRecylerView.FindViewHolderForLayoutPosition(pos)) as ItemCustomViewHolder; 
        }

这是我的问题,当我在最后一个视图中写自动完整列表出现在错误的地方任何提示如何解决我的问题

enter image description here

0 个答案:

没有答案