2
我有一個可擴展列表,並且當您單擊某個子項目而不是一個組時,我想要更改整個佈局。我嘗試選擇像這樣的子項目,它會更改所有項目。在可擴展列表中更改自定義項目的整個佈局onchildclicklistener
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;
}
任何解決方案?