在可扩展ListView(Android)中如何通过单击位置0处的子视图文本来更改位置2处的子视图文本

时间:2016-08-10 11:27:17

标签: expandablelistview

这里我有一个带有一个TextView和2个ImageView的自定义ChildView。现在,当我点击位置0处的孩子时,我将在位置2处更改子项Textview的文本而不是相同的第0位置。我已搜索但未获得实际解决方案。

mDrawerLeftList.setOnChildClickListener(新 ExpandableListView.OnChildClickListener(){

        public int i;
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, final int childPosition, long id) {
            childPos=childPosition;
            v.setSelected(true);
            System.out.println("childPosition " + childPosition);
             txtListChild = (TextView) v.findViewById(R.id.tvChildItems);
            ivChildleft = (ImageView) v.findViewById(R.id.ivChldLeft);
             ivchildRight = (ImageView) v.findViewById(R.id.ivChildRight);
            if(groupPosition == 1)
            {
                switch (childPosition)
                {
                    case 0:

                        if (ivchildRight.getDrawable().getConstantState().equals
                                (getResources().getDrawable(R.drawable.ic_officon_timer).getConstantState())) {
                            ivChildleft.setImageResource(R.drawable.ic_smenu_moonactive);
                            ivchildRight.setImageResource(R.drawable.ic_onicon);
                            txtListChild.setTextColor(Color.parseColor("#ffffff"));
                            if(timerWithPauseBreak != null) {

                                if(timerWithPauseBreak.isRunning()) {
                                    isTimerBreak = false;
                                    if(timerWithPauseBreak != null)
                                        timerWithPauseBreak.cancel();

                                    timerWithPauseBreak = null;
                                }

                            }
                            else
                            {
                                isTimerBreak = true;
                                /*At this position I want to change text of textview at child's position 2  not current position's textview's text 
                                ex. getChild(2).txtListChild.setText("Text Changed");
                                */
                            }

                        }

                        else
                        {
                            ivChildleft.setImageResource(R.drawable.ic_smenu_mooninavc);
                            ivchildRight.setImageResource(R.drawable.ic_officon_timer);
                            txtListChild.setTextColor(Color.parseColor("#891b70"));

                        }
                        break;

                    case 2:
                        pickerDialogBreak.show();
                        break;
                }

            }


            return false;

        }
    });

0 个答案:

没有答案