Robin Joseph
Robin Joseph

Reputation: 117

How to get the TextView and Button list from a view

First, sorry for my English and my knowledge, I'm a french Android Studio beginner.

I've a view in a fragment named root : View root = inflater.inflate(R.layout.fragment_about, container, false); defined in onCreateView. In this view, I've four buttons and four textview, each textview being assigned to a button. And my idea is to hide and show the textview when the user click the assigned button.

So I've defined an onClickListener for each button, and the parameter of this Listener is "this" : mAboutPartButton1.setOnClickListener(this);. So I suppose that "this" means the current view.

I then set the onClick void whith a View parameter, and I would like get the Textview list present in the view to hide and show the appropriated Textview.

The problem is that I don't know how can I get this list of Textviews.

Thank you for all your answers !

Upvotes: 1

Views: 57

Answers (1)

Kishan Maurya
Kishan Maurya

Reputation: 3394

onClick(View v) {
            switch (v.getId()) {
                case R.id.text1:
                    // do your stuff
                    break;

                case R.id.text2:

                    //do your stuff
                    break;
            }

Upvotes: 1

Related Questions