我有一个可扩展列表,当您单击子项而不是组时,我想更改整个布局。我尝试像这样选择子项目,它会更改所有项目。
while(parent.getChildAt(i)!=null){
do something..
}
这是代码:
private OnChildClickListener menuListOnChildClickListener = new OnChildClickListener()
{
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
{
//change whole layout of whole children with an inflator
//change the one clicked with another inflator
v.setBackgroundColor(Color.BLACK);
Toast.makeText(getApplicationContext(), "Tıklandı"+childPosition, Toast.LENGTH_SHORT).show();
switch(childPosition){
case 1:
relativeLayout_sagOrtaEkranlar.setVisibility(v.INVISIBLE);
relativeLayout_sagOrtaAnasayfa.setVisibility(v.VISIBLE);
break;
case 2:
relativeLayout_sagOrtaEkranlar.setVisibility(v.VISIBLE);
relativeLayout_sagOrtaAkilliEv.setVisibility(v.VISIBLE);
relativeLayout_sagOrtaAkilliEvPerde.setVisibility(v.INVISIBLE);
relativeLayout_sagOrtaAnasayfa.setVisibility(v.INVISIBLE);
break;
case 3:
relativeLayout_sagOrtaEkranlar.setVisibility(v.VISIBLE);
relativeLayout_sagOrtaAkilliEv.setVisibility(v.INVISIBLE);
relativeLayout_sagOrtaAkilliEvPerde.setVisibility(v.VISIBLE);
relativeLayout_sagOrtaAnasayfa.setVisibility(v.INVISIBLE);
break;
default:
break;
}
return true;
}
任何解决方案?