Код выглядит следующим образом:
Код: Выделить всё
Код: Выделить всё
public class EditTextWithIcon extends LinearLayout {
private EditText editText;
private ImageView imageView;
public EditTextWithIcon(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.EditTextWithIcon, 0, 0);
String hint = a.getString(R.styleable.EditTextWithIcon_custom_hint);
boolean focusable = a.getBoolean(R.styleable.EditTextWithIcon_focusable, true);
int iconSrc = a.getResourceId(R.styleable.EditTextWithIcon_icon_src, -1);
a.recycle();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.edit_text_with_icon, this, true);
editText = findViewById(R.id.editTextWithIconEditText);
imageView = findViewById(R.id.editTextWithIconImage);
editText.setHint(hint);
editText.setFocusable(focusable);
imageView.setImageResource(iconSrc);
}
public void setText(String text){
editText.setText(text);
}
public String getText(){
return editText.getText().toString();
}
}
Код: Выделить всё
Когда я пытаюсь получить к нему доступ из своего представления, например app:test="@={viewModel.title }" Я получаю следующую ошибку:
****msg: Невозможно найти метод получения для атрибута 'app:test' с типом значения java.lang.String
Знаете ли вы, почему метод получения не распознается, а метод установки распознается?
Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/786 ... m-elements