Android的,如果我用一个CustomAdapter如何访问我的自定义列表视图? [英] Android how to access views from my custom list if I use a CustomAdapter?
问题描述
在我的申请,我有的ListView
这是由我的CustomAdapter(即ArrayAdapter)设置。 CustomAdapter已ViewHolder它实现这也在我的CustomList所有视图引用。
现在的问题是我怎么能访问的意见,我CustomList(如EditText上下文code)的类层次结构是像
In my application, I have ListView
which is set by my CustomAdapter (i.e. ArrayAdapter). CustomAdapter has ViewHolder implemented in it which has references to all the views in my CustomList.
Now my question is how can I access the views in my CustomList (like EditText in below code) as the class hierarchy is like
public class BaseActivityClass{
...
class CustomAdapter{
...
public class ViewHolder{
EditText et;
...
}
}
}
从我的活动BaseActivityClass?
from my activity BaseActivityClass?
推荐答案
您可以给你的查看
一个唯一的ID( View.setId()
)或标记( View.setTag()
在 getView()
法)和然后用 findViewById()
或 findViewByTag()
来使用它们。
You can give your View
a unique id (View.setId()
) or tag (View.setTag()
) in your getView()
method and then use findViewById()
or findViewByTag()
to use them
这篇关于Android的,如果我用一个CustomAdapter如何访问我的自定义列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!