I'm using editText in recyclerView, I want to display or edit the 2nd one only if the 1st is filled android java.
This is a quick solution of mine: In your adapter, create a flag int currentFilled = -1;
and update this flag whenever your editText is filled Like this:
EditText edt1 = new EditText(this);
edt1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void afterTextChanged(Editable s) { }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() >0){
// this is when your edt1 is filled
// edt2.setEnabled(true); // You can enable your edt2 or whatever here
// edt2.setVisibility(View.VISIBLE);
currentFilled = itemPosition;
notifyItemChanged(itemPosition+1) // position you wan to display or edit the edt
} else {
// when edt1 is not filled
/// TODO do what ever you want
}
}
});
Then in your ViewHolder check if currentFilled == itemPosition-1
==>>
edt.setEnabled(true); // You can enable your edt2 or whatever here
// or
edt.setVisibility(View.VISIBLE)
it's may get some issues or not depending on your requirements. Happy coding:))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.