首页 > 代码库 > Android Bug BaseExpandableListAdapter, getChildView
Android Bug BaseExpandableListAdapter, getChildView
@Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { Log.d(TAG, "getChildView() group="+groupPosition+", child="+childPosition); final String children = (String) getChild(groupPosition,childPosition); if (convertView == null || children != ((ViewHolder) convertView.getTag()).text.getText()) { Log.d(TAG, "getChildView() - initialize converView"); LayoutInflater inflater = LayoutInflater.from(context); convertView = inflater.inflate(R.layout.expandable_list_row, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) convertView.findViewById(R.id.textView1); viewHolder.image = (ImageView) convertView.findViewById(R.id.imageCheck); convertView.setTag(viewHolder); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("test","group="+groupPosition+", child="+childPosition); final ImageView imageCheck = (ImageView)v.findViewById(R.id.imageCheck); imageCheck.setVisibility(ImageView.VISIBLE); int dialogType = getAntecedentType(groupPosition, childPosition); int antecedentId = getAntecedentId(groupPosition, childPosition); if(antecedentId != -1) { MedicalAntecedentDialog dialog = dialogs.get(antecedentId); if(dialog != null) { dialog.show(); } else { MedicalAntecedentDialog dialog2 = new MedicalAntecedentDialog(context, children, dialogType); dialogs.append(antecedentId, dialog2); dialog2.show(); } } } }); } ViewHolder holder = (ViewHolder) convertView.getTag(); holder.text.setText(children); return convertView; }
这里出现问题:
if (convertView == null || children != ((ViewHolder) convertView.getTag()).text.getText()) { Log.d(TAG, "getChildView() - initialize converView");
Group1里前9项都被初始化了,而第十个和第十一个没有,第十二个元素初始化正确。不知道为什么。。。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。