1

i'm working with expandable recycler view from bignerdranch. Inside my child view, i placed a edit text where user can leave a comment regarding an issue shown on the parent view.

My problem is that, i wanted the user input to be save after the edit text loose focus. (In this case, i have 3 parents, and each parent has 1 editText). But when i input edit text 1 and focus on edit text 2 without inputing... edit text 2 would take up edit text 1 input after it loose focus.

I try using text watcher, and put the codes inside after text changes.. but the app freezes and stopped working after a while. If there a better way for me to save accordingly?

mCatatan is my editText.

@Override
    public void onBindChildViewHolder(final ATPChildViewHolder atpChildViewHolder, int i, Object childObject) {
        final ATPChild atpChild = (ATPChild) childObject;

        final String text = atpChildViewHolder.mCatatanInput.getText().toString();
        if(!text.equals("")) {
            atpChild.setDetail(text);
            atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
        } else {
            atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
        }


//        todo: fixed catatan being saved to another catatan
        atpChildViewHolder.mCatatanInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    Log.d(TAG, "onFocusChange: ");
                    atpChild.setDetail(atpChildViewHolder.mCatatanInput.getText().toString());
                    atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
                }
            }
        });
    }

0 Answers0