I want to check infalted view Edittext null or not if it is null then I want to set error below particular Edittext view. I search on google but not found a satisfied answer.
This is my code I write for inflate view.
void inflateData(int passenger) {
LinearLayout linearLayout = findViewById(R.id.linear_addTraveller);
LayoutInflater inflater = getLayoutInflater();
for (int i = 0; i < passenger; i++) {
View view = inflater.inflate(R.layout.inflate_flight_traveller, null);
view.setId(i);
view.addchi
main_view = view;
TextView txt_trave = view.findViewById(R.id.txt_traveller);
final TextView txt_mr = view.findViewById(R.id.txt_mr);
final TextView txt_ms = view.findViewById(R.id.txt_ms);
final TextView txt_mrs = view.findViewById(R.id.txt_mrs);
final TextInputLayout txtInput_firstName = view.findViewById(R.id.txtInput_firstName);
TextInputLayout txtInput_middleName = view.findViewById(R.id.txtInput_middleName);
TextInputLayout txtInput_lastName = view.findViewById(R.id.txtInput_lastName);
final EditText etx_firstName = view.findViewById(R.id.etx_firstName);
EditText etx_middleName = view.findViewById(R.id.etx_middleName);
EditText etx_lastName = view.findViewById(R.id.etx_lastName);
if (Common.INT_ADULT > i) {
txt_trave.setText("Adult " + (i + 1));
} else if ((Common.INT_ADULT + Common.INT_CHILD) > i) {
txt_trave.setText("Child " + ((i + 1) - Common.INT_ADULT));
} else if ((Common.INT_ADULT + Common.INT_CHILD + Common.INT_INFANTS) > i) {
txt_trave.setText("Infant " + ((i + 1) - (Common.INT_ADULT + Common.INT_CHILD)));
}
txt_mr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonClick(txt_mr, txt_ms, txt_mrs);
}
});
txt_ms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonClick(txt_ms, txt_mr, txt_mrs);
}
});
txt_mrs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonClick(txt_mrs, txt_mr, txt_ms);
}
});
linearLayout.addView(view);
}
}