我怎么知道的意见ID的,如果我在同一个父充气视图上多次点击链接? [英] How do I know the ID's of views if I am inflating a view multiple times in the same parent on button click?

查看:188
本文介绍了我怎么知道的意见ID的,如果我在同一个父充气视图上多次点击链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有困难的情况下,让我这么说吧,我希望用户使用我的3个文本字段来设置报警,在信息填写后的数据,我给他一个选项来设置此另一个报警目的,我使用一个按钮。我这是在一个child.xml文件中定义的表格布局三表行,每一个元素都有一个id集。在我的活动,我就膨胀按钮单击事件child.xml多次,我能够成功地夸大它很多次我想要的。但我的问题是,因为我膨胀相同的XML文件多次(我不知道有多少次)在运行时,我很困惑,我将​​如何检索特定的文本字段,如TextViews的数据,并通过识别它们唯一的ID,因为我必须这样做。
你怎么做呢?

I have a difficult situation, let me put it this way, I want the user to use my 3 text-fields to set data for alarm and after filling in the information, I give him an option to set another alarm for this purpose I use a button. I have three table rows in a table layout which are defined in a child.xml file and every element has an Id set. In my activity, I inflate child.xml multiple times on button click event and I am able to successfully inflate it as many times as I want. But my problem is since I am inflating the same xml file many times(I don't know how many times) at runtime, I am confused as of how would I retrieve the data from particular text-fields like TextViews and identify them by a unique IDs since I am required to do so. How do you go about it?

推荐答案

我会从基础开始。

<Layout>
<Button1>
</layout>

现在在活动

Button btn;View view1=null;
///Inflate file if view is null
first time when you inflating
view1=inflate
 btn=view1.findViewbyid();

现在假设你有夸大另一种观点却厂景值不会改变,那么BTN预订购包含该参考button.And当它成为visible.It将工作像正常的按钮。

Now suppose you have inflate another view but view1 value is not changed then btn willl contain reference for that button.And when it became visible.It will work as like normal button.

这篇关于我怎么知道的意见ID的,如果我在同一个父充气视图上多次点击链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆