码迷,mamicode.com
首页 > 移动开发 > 详细

Android Bug BaseExpandableListAdapter, getChildView

时间:2014-05-07 11:02:33      阅读:422      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   class   code   java   

bubuko.com,布布扣
        @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;
        }
bubuko.com,布布扣
这里出现问题:
if
(convertView == null || children != ((ViewHolder) convertView.getTag()).text.getText()) { Log.d(TAG, "getChildView() - initialize converView");

Group1里前9项都被初始化了,而第十个和第十一个没有,第十二个元素初始化正确。不知道为什么。。。

Android Bug BaseExpandableListAdapter, getChildView,布布扣,bubuko.com

Android Bug BaseExpandableListAdapter, getChildView

标签:android   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/davesuen/p/3712932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!