我的适配器中有以下代码,它使用方法“et_settingValue.setId(setting.getId());”动态创建 EditTexts 和设置 ID。在 Setting 类的每个实例中都会创建一个 Editbox,它还包含一个用于存储其 id 的变量。
这部分已经正常工作,但现在我需要通过 ID 访问所有创建的 EditTexts 并获取其数据。如果可能,我想避免创建另一个数组来存储 EditText,因为我已经有了它们的 ID。
有没有办法使用我已经拥有的动态 ID 来做到这一点?
EditText et_settingValue = (EditText) view.findViewById(R.id.et_settingValue);
et_settingValue.setText(setting.getValue().trim());
et_settingValue.setId(setting.getId());
更新 1
在我的活动中,我正在尝试这样做:
EditText et = new EditText(listView.getContext());
//loop to get each object child
settingConfig.getConfigName(); //ok
settingConfig.getConfigValue(); //ok
settingConfig.getConfigId(); //ok
et = (EditText) listView.findViewById(settingConfig.getConfigId()); //not working
et.getText(); // off course it will not working
非常感谢