如何从动态创建的目录中查找编辑文本框和微调框

时间:2018-08-10 09:50:10

标签: android android-layout

我无法在布局中找到微调框和编辑文本

代码如下所示,它只能多次查找出EditText

try {
                int count = my_linear_layout1.getChildCount();
                //EditText ed[] = new EditText[count];
                for (int i = 1; i < count; i++) {
                    View row = my_linear_layout1.getChildAt(i);

                    row = my_linear_layout1.findFocus();
                    if(row instanceof EditText)
                    {
                        // you got the Edit Text  if (v.getClass().equals(TextView.class))
                        EditText textOut = (EditText) row.findViewById(R.id.OBSpn);
                        String data = textOut.getText().toString();
                    }

                    else if(row instanceof Spinner)
                    {
                        // you got the Spinner
                        Spinner Spin = (Spinner) row.findViewById(R.id.SPNOBS);
                        String data1 = Spin.getSelectedItem().toString();
                    }

                }

            } catch (Exception e) {
                e.printStackTrace();
            }

1 个答案:

答案 0 :(得分:1)

使用ListView代替LinearLayout。 遵循此文档。 https://developer.android.com/reference/android/widget/ListView

我的问题是为什么ScrollView不能成为父布局,而不需要相对布局。

dpkg -l "*cuda*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  cuda-command-l 9.0.176-1    amd64        CUDA command-line tools
ii  cuda-core-9-0  9.0.176.3-1  amd64        CUDA core tools
ii  cuda-cublas-9- 9.0.176.4-1  amd64        CUBLAS native runtime libraries
ii  cuda-cudart-9- 9.0.176-1    amd64        CUDA Runtime native Libraries
ii  cuda-cudart-de 9.0.176-1    amd64        CUDA Runtime native dev links, he
ii  cuda-cufft-9-0 9.0.176-1    amd64        CUFFT native runtime libraries
ii  cuda-curand-9- 9.0.176-1    amd64        CURAND native runtime libraries
ii  cuda-cusolver- 9.0.176-1    amd64        CUDA solver native runtime librar
ii  cuda-cusparse- 9.0.176-1    amd64        CUSPARSE native runtime libraries
ii  cuda-driver-de 9.0.176-1    amd64        CUDA Driver native dev stub libra
ii  cuda-license-9 9.0.176-1    amd64        CUDA licenses
ii  cuda-misc-head 9.0.176-1    amd64        CUDA miscellaneous headers
ii  cuda-repo-ubun 9.1.85-1     amd64        cuda repository configuration fil
un  libcuda1-340   <none>       <none>       (no description available)
ii  nvinfer-runtim 1.0-1        amd64        nvinfer-runtime-trt repository co
ii  nvinfer-runtim 1-1          amd64        nvinfer-runtime-trt repository co