简体   繁体   English

Xamarin Android中的表格布局

[英]Table Layout in Xamarin Android

I just want to know if it's possible to click a certain data in a row from a table layout. 我只想知道是否可以从表布局中单击某一数据。 For example I have a row with 3 columns, and I just want to click the data in the second column. 例如,我有一个包含3列的行,我只想单击第二列中的数据。 Is it possible? 可能吗?

yes it is in a similar way like this: (If you don't have Fragments delete the view. below) 是的,它采用类似的方式:(如果您没有片段,请删除该视图。)

var _view = view.FindViewById(Resource.Id.list)
if (_view.ChildCount> 0){
Button _button = (Button)_view.Get(0).GetChildAt(0);
}

Because you have a lot of similar objects on a list this is the only way i think to access them, Remember that item position is relative to the current visible items on the screen and you cant access items that are not visible. 因为列表上有很多类似的对象,所以这是我访问它们的唯一方法,请记住,项目位置是相对于屏幕上当前可见的项目而言的,因此您无法访问不可见的项目。

After that you define .onclick as usual. 之后,您照常定义.onclick。

You can Also give id on the TableRow from the axml and access it like this: 您还可以通过axml在TableRow上提供id并按如下方式访问它:

TableRow row = (TableRow)FindViewById( Resource.Id.Row1 );
row.SetOnClickListener += Something;

What are you trying to do with the TableRow? 您想使用TableRow做什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM