单击/键入编辑文本后,我不知道如何删除编辑文本焦点。当我单击折叠按钮时,应用程序停止运行。这是它给出的错误:-
致命异常:主进程:my.mimos.fssm.fosimapp,PID:3915 java.lang.IllegalArgumentException:参数必须是该视图在 android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4882) 的后代
我正在研究bignerdranch的可扩展回收站视图。我的父列表视图有一个文本视图(列表的名称)和一个折叠按钮(它充当子视图的 google)。至于我的子视图,我添加了一个editText,可以在其中使用来发表关于 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());
}
}
});
}
}
我尝试了很多东西,但似乎对我不起作用。这是我的可扩展回收站视图。在此处输入图像描述