How to find an attribute name, rather than its value from a model in Android Java.
I've written an android method to scan the data from the view and to return it to the model (by Declared).
To detect the attribute identity, I've defined a tag in the view using a hard code string.
Now, when I want to rename the attribute in the model, I change the tag name in the code, using hard code.
But, I need to find attribute name from the model as dynamic, not from the hard code string.
for example in this model
public class CodeNameModel {
private Long Code;
private String Name;
public Long getCode() {
return Code;
}
public void setCode(Long code) {
Code = code;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
}
and in the code
CodeNameModel codeNameModel = new CodeNameModel();
codeNameModel.setCode(3L);
codeNameModel.getCode();
I need the model to return "Code" and "Name" in the string value, not their value like 3. I mean, I need the attribute name in the string format for example a method to return "CODE" in string format when call getCodeName().
codeNameModel.getcode();
answer is 3;
I need below method
codeNameModel.getcodeName();
I need return "Code" in string format.