[英]how to validate recyclerView items when click on button in android
i have 2 EditText in recyclerView item. 我在recyclerView项目中有2个EditText。 for example, first name and last name!
例如名字和姓氏! and i have fragment, have this recyclerView and a button!
我有片段,有这个recyclerView和一个按钮! i want when clicked on button, validate all EditText in recyclerView items and saved users to ArrayList.
我想要单击按钮时,验证recyclerView项目中的所有EditText并将用户保存到ArrayList。 pic
PIC
Try This, It's work on my application 试试这个,在我的应用程序上工作
//validation controls
public boolean Validatioin() {
if (first_name.getText().toString().length() <= 0) {
first_name.setError(getString(R.string.valid_first_name));
return false;
} else if (lest_name.getText().toString().length() <= 0) {
lest_name.setError(getString(R.string.valid_first_name));
return false;
} else {
strFirstName = first_name.getText().toString();
strLastName = lest_name.getText().toString();
return true;
}
}
}
// interface //接口
public interface user_details {
void userDetails(String firstName,String
Lastname);
}
// in Adapter class //在Adapter类中
userDetails.userDetails(strFirstName,strLastName);
// constructor //构造函数
private userDetails userDetails;
public adapterName(Context context,userDetails userDetails)
{
this.userDetails = userDetails;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.