我正在建立一個android應用程序,我正在創建動態EdittextView。我需要顯示用戶輸入的整數之和。下面是我的代碼來創建動態EdittextView:如何在android中獲取動態創建的EditText的值?
for (int i = 1; i < ZipRunApplication.ConfigLeg; i++){ LayoutInflater inflater = null; inflater = (LayoutInflater) getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View mLinearView = inflater.inflate(R.layout.drop_money, null); TextView droxTextView = (TextView) mLinearView.findViewById(R.id.dropTextView); final TextView position = (TextView) mLinearView.findViewById(R.id.position); final TextView Amount = (TextView) mLinearView.findViewById(R.id.Amount); final EditText dropEditTextView = (EditText) mLinearView.findViewById(R.id.dropEditext); dropEditTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { Amount.setText(dropEditTextView.getText().toString()); // } }); droxTextView.setText("Amount to be pick From Drop " + String.valueOf(i)); position.setText(String.valueOf(i)); droxTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); container.addView(mLinearView); }
可以在任何一個可以幫助我得到的所有EdittextView的總和創建動態地。