I want to remove the container of my TextInputLayout on endDrawable click.
(我想在endDrawable单击上删除TextInputLayout的容器。)
I have multiple instances of these containers. (我有这些容器的多个实例。)
I have 2 questions: (我有两个问题:)
When I first initialise the onClick()
method for each one in a for loop in onCreate()
, do I have to use getId()
to find the parent container of each TextInputLayout?
(当我第一次在onCreate()
的for循环中为每个方法初始化onClick()
方法时,是否必须使用getId()
查找每个TextInputLayout的父容器?)
How can I use removeView()
, getParent()
(or otherwise) methods to remove the required view?
(如何使用removeView()
, getParent()
(或其他方法)删除所需的视图?)
phoneNumberLayoutViews[v].setEndIconOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// Remove parent layout
}
});
Small Edit: I had to call getParent()
multiple times to remove the parent I wanted.
(小修改:我必须多次调用getParent()
才能删除想要的父级。)
First, only the drawable was removed, then the TextInputEditText (I think), then the TextInputLayout, then the container. (首先,只删除可绘制对象,然后删除TextInputEditText(我认为),然后删除TextInputLayout,然后删除容器。)
((ViewGroup) view.getParent().getParent()
.getParent()
.getParent()
.getParent())
.setVisibility(View.GONE);
ask by George translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…