如何在android中创建带边框的动态表

如何在android中创建带边框的动态表,android,android-layout,Android,Android Layout,我有一张动态表。当用户输入数量时,值(TextView)应更新(数量*价格)。 我的问题是,我正在动态创建TextView&EditText。如何获取文本视图的Id EditText txtQty = new EditText(this); txtQty.setId(i); txtQty.setVisibility(1); txtQty.setHint("0.00"); txtQty.setInputType(InputType.

我有一张动态表。当用户输入数量时,值(
TextView
)应更新(数量*价格)。 我的问题是,我正在动态创建
TextView
&
EditText
。如何获取
文本视图的Id

 EditText txtQty = new EditText(this);
        txtQty.setId(i);
        txtQty.setVisibility(1);
        txtQty.setHint("0.00");
        txtQty.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

        tr.addView(txtQty); 
        InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        mgr.showSoftInput(txtQty, InputMethodManager.SHOW_IMPLICIT);

        ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))  
        .hideSoftInputFromWindow(txtQty.getWindowToken(), 0);

        txtQty.addTextChangedListener(new TextWatcher() {
            public void afterTextChanged(Editable s) { 
                Log.v("TAG", "afterTextChanged" + s.toString());
            }

            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
                Log.v("TAG", "beforeTextChanged");
            }

            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Log.v("TAG", "onTextChanged");
            }
        });

        TextView txtVal = new TextView(this);
        txtVal.setTextSize(1, 12);
        createView(tr, txtVal,"0.00");
postertextchanged()
方法中,我想设置值(
txtVal
),例如
txtVal.setText(215847.00)


我们如何在
PostTextChanged()
方法中调用
txtVal

请在
addTextChangedListener()之前尝试声明您的
txtVal
。您可能需要将
txtVal
声明为
final TextView txtVal
。那么你应该能够设置
txtVal

的文本了,这是一个基本的小东西。我没有想到这一点。很好。