gpt4 book ai didi

c# - 使用 C# 在 Xamarin Studio 中从 ListView 获取 EditText 控件

转载 作者:太空宇宙 更新时间:2023-11-03 20:09:10 30 4
gpt4 key购买 nike

我正在使用带有 C# 的 Xamarin Studio。

我在 listview 适配器中添加了 EditText 控件。并且这个列表是动态填充的。

现在我想获取 activity 类中所有 EditText 的值。我怎样才能做到这一点?

`公共(public)类 PRDeptHeadApprovalDetailAdapter : BaseAdapter { 列出项目; Activity 背景;

    public PRDeptHeadApprovalDetailAdapter(Activity context, List<PRDeptHeadApprovalDetailAdapterInformation> items)
: base()
{
this.context = context;
this.items = items;
}

public override long GetItemId(int position)
{
return position;
}


public override string this[int position]
{
get { return items[position].ToString(); }
}


public override int Count
{
get { return items.Count; }
}

public override View GetView(int position, View convertView, ViewGroup parent)
{
var item = items[position];
View view = convertView; // re-use an existing view, if one is supplied
if (view == null) // no view to re-use, create new
view = context.LayoutInflater.Inflate(Resource.Layout.PRDeptHeadApprovalDetailAdapter, null);
// set view properties to reflect data for the given row
view.FindViewById<TextView>(Resource.Id.lbltdPermNo).Text = item.lbltdPermNo;
view.FindViewById<TextView>(Resource.Id.lbltdItemName).Text = item.lbltdItemName;
view.FindViewById<TextView>(Resource.Id.lbltdJustification).Text = item.lbltdJustification;
view.FindViewById<TextView>(Resource.Id.lbltdSrce).Text = item.lbltdSrce;
view.FindViewById<TextView>(Resource.Id.lbltdQuantity).Text = item.lbltdQuantity;
EditText txtApproveQuantity = view.FindViewById<EditText>(Resource.Id.lbltdApproveQuantity);
txtApproveQuantity.Text = item.lbltdApproveQuantity;
// return the view, populated with data, for display
return view;
}
}`

最佳答案

首先创建ListView适配器的对象

titleAdapter = new TitleAdapter();

然后你可以通过 ListView 的position得到listview EditText的Each position

View view = titleAdapter .getView(position, null, null);
EditText edittext= (EditText ) view.findViewById(R.id.edittext_id_here);
edittext.getText();

关于c# - 使用 C# 在 Xamarin Studio 中从 ListView 获取 EditText 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21252308/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com