Actually there're lots of alternatives. One of them is to use HashMap
with appropriate data and TextView
:
private HashMap<String, TextView> checkMap = new HashMap<String, TextView>();
public void onCreate(Bundle savedInstanceState){
checkMap.put("DataA", textViewA);
checkMap.put("DataB", textViewB);
//...
}
public boolean checkFields(){
for (Map.Entry<String, TextView> entry : checkMap.entrySet()) {
String checkData = entry.getKey();
TextView textView = entry.getValue();
if(!textView.getText().toString().equals(checkData))
return false;
}
return true;
}
Other options could be found here: How to avoid a lot of if else conditions