我的编辑文字有问题。我在子视图中为每个组编辑了文本,我可以动态添加新组,当我键入最初可以放入屏幕的组的编辑文本时,焦点仍然指向编辑文本,但是当我点击编辑文本以键入我需要向下滚动的那些组,在我键入任何第一个字符后,编辑文本焦点突然消失并随机指向这怎么可能发生?我希望这张照片足以让你理解。我的适配器代码:
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.personal_loan_list_group, null);
TextView titleText = (TextView) convertView.findViewById(R.id.lblListHeader);
Button deleteBtn = (Button) convertView.findViewById(R.id.deleteBtn);
titleText.setText("Group" + " " + (groupPosition+1));
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customer.removePersonalLoan(groupPosition);
notifyDataSetChanged();
}
});
return convertView;
}
@Override
public View getRealChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.personal_loan_list_item, null);
final CustomEditText installmentText = (CustomEditText) convertView.findViewById(R.id.installmentET);
installmentText.setTag("amount");
installmentText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
try {
installmentText.removeTextChangedListener(this);
installmentText.setText("999");
installmentText.addTextChangedListener(this);
} catch (Exception ex) {
ex.printStackTrace();
installmentText.addTextChangedListener(this);
}
}
});
return convertView;
}