2014-05-21 4 views
1

내 안드로이드 앱에서 버튼 클릭을 기반으로 자식보기를 동적으로 추가해야합니다. 나는 어떻게 해야할지 모르겠다. 나는 샘플 이미지를 공유한다. 어느 날 enter image description here확장 가능한 목록보기에 자식보기 항목을 동적으로 추가하십시오.

+0

내 질문 위의 링크가 모두 – user1517638

+0

단순히 XML에서 뷰를 생성 서로 다른 r에 위치, 다음 온 클릭 버튼 setvisibility 또는 사라 –

+0

귀하의 질문은 우리가 중복 가정 할 수 있도록 모호합니다. 그렇지 않은 경우 : 무엇이/왜 다른가에 대한 자세한 정보를 제공하고 복제본이 제거됩니다. – ben75

답변

1

내 질문에 대한 답변을 찾았습니다. 모든 버튼 클릭만으로 XML 레이아웃을 부 풀릴 수 있습니다. 레이아웃을 하나씩 추가 할 수 있습니다. 코드가

LayoutInflater IInflater = (LayoutInflater) context 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    String[] names = { "Joe", "Jane", "Herkimer" }; 
    while (run >= 1) { 

     View storeitems = IInflater.inflate(R.layout.product_child_item, 
       null); 
     productCode = (TextView) storeitems.findViewById(R.id.productCode); 
     productName = (TextView) storeitems.findViewById(R.id.productName); 
     noOfQuantity = (TextView) storeitems 
       .findViewById(R.id.noOfQuantity); 
     int i = run - 1; 
     productCode.setText(names[i]); 
     linearLayout.addView(storeitems, 0); 
     run--; 
    } 
0

당신의 활동에 OnChildClickListener을 구현하고이 방법을 implemet 도와주세요 알고 있다면 ..

@Override 
public boolean onChildClick(ExpandableListView parent, View v, 
     int groupPosition, int childPosition, long id) { 

      //Add new chid data in your list (ex ArrayLis or Array whatever you use) 
      adapter.notifyDataSetChanged() // BaseExpandableListAdapter's adapter... 


    return true; 
} 

는 당신을 위해 일을 일입니까?

관련 문제