找到匹配的标签,所有的纺纱厂 [英] find all spinners that match a tag

查看:165
本文介绍了找到匹配的标签,所有的纺纱厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能得到一个列表,或者找出所有微调匹配特定的标签呢?

Is it possible to get a list or find all Spinner that match a specific tag?

我希望用户能够在运行中添加新的微调窗口小部件,但我需要能够从每个<$ C $动态获取值C>微调。

I would like the user to be able to add new Spinner widgets on the fly, but I need to be able to dynamically get the values from each Spinner.

的jQuery ,我可以选择按 $匹配一类的所有元素('。myClassSelector')。每一个()。可这,或类似的东西,可以在Android中做了什么?

In jQuery, I can select all elements that match a class by $('.myClassSelector').each(). Can this, or something similar, be done in Android?

更新
所有的微调是在一个特定的的LinearLayout 是在XML中指定。布局被用来作为所有的纺纱的容器。

UPDATE All spinners are in a specific LinearLayout that is specified in XML. The layout is used as a container for all of the spinners.

推荐答案

我认为你可以在其中previously增加了布局的所有孩子的微调并检查孩子是微调或没有。

I think you can get all the child of the layout in which you previously added the Spinner and check if the child is Spinner or not.

    LinearLayout ll = //Your Layout this can be any Linear or Relative layout 
                     //in which you added your spinners at runtime ;

    int count = ll.getChildCount();
    for(int i =0;i<count;i++)
    {
        View v = ll.getChildAt(i);
        if(v instanceof Spinner)
        {
            // you got the spinner
            Spinner s = (Spinner) v;
            Log.i("Item selected",s.getSelectedItem().toString());
        }
    }

这篇关于找到匹配的标签,所有的纺纱厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆