標籤:android style blog class code java
@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項都被初始化了,而第十個和第十一個沒有,第十二個元素初始化正確。不知道為什麼。。。