Try using the logic below
View v = layout.getChildAt(i);
if (v instanceof EditText) {
EditText et = (EditText) v;
//Do stuff
} else if (v instanceof TextView) {
//Do other stuff
}
Since EditText
is a subclass of TextView
, you need to check for EditText
first. An EditText
will test positive as an instance of TextView
.