I don't know how to remove edit text focus after I clicked / type on the edit text. The application stopped running when I clicked on the collapse button. This is the error it gives out:-
FATAL EXCEPTION: main Process: my.mimos.fssm.fosimapp, PID: 3915 java.lang.IllegalArgumentException: parameter must be a descendant of this view at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4882)
I'm working on expandable recycler view by bignerdranch . My parent list view has a textview (the name of the list) and a collapse button (where it act as google for the child view). As for my child view, I added a editText , where use is enable to leave a comment regarding the textview.
ExpandableAdapter.java
import com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter;
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
public class ATPExpandableAdapter extends ExpandableRecyclerAdapter<ATPParentViewHolder, ATPChildViewHolder> {
LayoutInflater mInflater;
Context mContext;
ArrayList<ATPParent> mParentItemList;
public static final String TAG = ATPExpandableAdapter.class.getSimpleName();
public ATPExpandableAdapter(Context context, ArrayList<ATPParent> parentItemList) {
super(parentItemList);
mInflater = LayoutInflater.from(context);
mContext = context;
mParentItemList = parentItemList;
}
@Override
public ATPParentViewHolder onCreateParentViewHolder(ViewGroup viewGroup) {
View view = mInflater.inflate(R.layout.list_item_atp_parent, viewGroup, false);
return new ATPParentViewHolder(view);
}
@Override
public ATPChildViewHolder onCreateChildViewHolder(ViewGroup viewGroup) {
View view = mInflater.inflate(R.layout.list_item_atp_child, viewGroup, false);
return new ATPChildViewHolder(view);
}
// todo: continued here
@Override
public void onBindParentViewHolder(final ATPParentViewHolder atpParentViewHolder, final int i, ParentListItem parentObject) {
ATPParent atpParent = (ATPParent) parentObject;
atpParentViewHolder.mATP_textview.setText(atpParent.getTitle());
//when user clicked on parent view
atpParentViewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick: parentView");
}
});
atpParentViewHolder.mParentDropDownArrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick: expandable button");
}
});
}
@Override
public void onBindChildViewHolder(final ATPChildViewHolder atpChildViewHolder, int i, Object childObject) {
final ATPChild atpChild = (ATPChild) childObject;
String text = atpChildViewHolder.mCatatanInput.getText().toString();
if(!text.equals("")) {
atpChild.setDetail(text);
atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
} else {
atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
}
atpChildViewHolder.mCatatanInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
atpChild.setDetail(atpChildViewHolder.mCatatanInput.getText().toString());
atpChildViewHolder.mCatatanInput.setText(atpChild.getDetail());
}
}
});
}
}
I tried a lot of thing but not of it seemed to work for me. This is my expandable recycler view. enter image description here
you can use this library. It is very Useful Custom RecyclerViewAdapters for expanding and collapsing groups with support for multiple view types.
ExpandableRecyclerView:
implementation 'com.thoughtbot:expandablerecyclerview:1.3'
ExpandableCheckRecyclerView:
implementation 'com.thoughtbot:expandablecheckrecyclerview:1.4'
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.