Я недавно создал класс, который имеет текстовое представление и текст редактирования. Я использую текст редактирования, чтобы получить ввод от пользователя, и я хотел бы, чтобы мое текстовое представление отображало то, что вводит пользователь. Я должен отметить, что мои метки создаются динамически, и я не уверен, как ссылаться их. Не могли бы вы дать мне подсказку?
public TextView itemName(Context context){
final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final TextView itemName = new EditText(context);
itemName.setLayoutParams(lparams);
return itemName;
}
public EditText desiredQuantity(Context context) {
final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final EditText desiredQuantity = new EditText(context);
desiredQuantity.setLayoutParams(lparams);
desiredQuantity.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) {
itemName.setText(desiredQuantity.getText().toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
return desiredQuantity;
}
введите описание изображения здесь