Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

android - 删除TextInputLayout的父级(Remove parent of TextInputLayout)

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:

(我有两个问题:)

  1. 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的父容器?)

  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...