简体   繁体   English

如何从视图中获取 TextView 和按钮列表

[英]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.首先,对不起我的英语和知识,我是法国 Android Studio 初学者。

I've a view in a fragment named root: View root = inflater.inflate(R.layout.fragment_about, container, false);我在一个名为 root 的片段中有一个视图: View root = inflater.inflate(R.layout.fragment_about, container, false); defined in onCreateView.在 onCreateView 中定义。 In this view, I've four buttons and four textview, each textview being assigned to a button.在这个视图中,我有四个按钮和四个 textview,每个 textview 都分配给一个按钮。 And my idea is to hide and show the textview when the user click the assigned button.我的想法是在用户单击分配的按钮时隐藏和显示 textview。

So I've defined an onClickListener for each button, and the parameter of this Listener is "this": mAboutPartButton1.setOnClickListener(this);所以我为每个按钮定义了一个onClickListener,这个Listener的参数是“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.然后,我使用 View 参数设置 onClick void,并且我想在视图中获取 Textview 列表以隐藏和显示适当的 Textview。

The problem is that I don't know how can I get this list of Textviews.问题是我不知道如何获得这个 Textviews 列表。

Thank you for all your answers !感谢您的所有回答!

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

                case R.id.text2:

                    //do your stuff
                    break;
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从按钮上的列表视图自定义适配器获取所有textview数据 - How to get All textview data from List View Custom Adapter on Button Click 如何在Android的自定义列表视图中从TextView获取值 - How to get the value from TextView in a custom list view in android 如何使用textview创建一个列表视图并增加n减少按钮? - how to create a list view with textview and increase n decrease button? 如何从同一视图内的ListView适配器onClick按钮获取textView值? - How to get a textView value from ListView adapter onClick button inside same view? 如何从列表布局的textview获取总和? - How to get sum from textview in list layout? Android 如何从列表视图中获取 textview 字符串值 - Android how can i get the textview string value from list view 从textview上的列表视图中获取Selected项目,单击android - Get the Selected item from a list view on textview click in android 如何识别视图是Button还是Textview - How to identify if a view is Button or Textview 如何在单击按钮时从列表视图获取编辑文本值 - How to get edit text values from list view on button click 如何通过单击按钮从 RecyclerView 中的 TextView 和 Radio 按钮获取价值? - How to get value from TextView and Radio button in RecyclerView on click Button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM