2016-06-05 2 views
-1

안녕하세요, 저는 지금이 같은 목록이 필요합니다. 저는 expandlelist를 사용하고 있습니다.하지만 메인 아래에 하위 목록을 가져 오는 방법을 알지 못합니다. V 드롭 화살표를 보여 그냥다중 레벨 확장 ListView? 안드로이드

제목 V 질문 V 대답 대답 대답 질문 V 대답 대답 대답

제목 V 질문 V 대답 대답 대답

+0

가능한 [안드로이드의 ExpandableListView에 3 단계 ListView를 추가하는 방법] 가능한 복제본 (http://stackoverflow.com/questions/32880281/how-to-add-three-level-listview-in-expandablelistview-in -기계적 인조 인간) –

답변

0

그런 것을 구현하고 있었는지, AnimatedExpandableListView을 사용하고 있었고, 그 하나의 어댑터로 재연이 이루어졌다. 반복적으로 es 자체. 하나 더 하위이없는 그 최종 사용자가 하위 범주에 대한 두 견해를 필요

: 지금은 괜찮

public CategoriesExpandableListAdapter(Context context, HashMap<CategoryModel, List<CategoryModel>> hashMap, int parentCategoryId, int paddingLevel){ //... parent category is category from which start adapter (you search for it and init adapter according it, padding level i used to make padding from left for sub categories) 

:이 어댑터에 대한 생성자

private HashMap<CategoryModel, List<CategoryModel>> mMainMenuExpandableList; // this is hashmap for categories; 

:

당신은 데이터가 필요 범주와 또 다른 하나는 AnimatedExpandableListView을 포함하고 있으며이 뷰 홀더를 만들 때 다른 어댑터를 생성하여 초기화합니다. 이 목록 가시성을 사라지도록 설정했으며, 사용자가 드롭 다운 애니메이션을 적용한 상태에서만 사용자가이 탭을 표시 할 때만 표시합니다.

여기
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/item_container" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:focusable="false" 
    android:clickable="true" 
    android:background="@drawable/custom_background" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
     android:id="@+id/item_layout" 
     android:layout_width="match_parent" 
     android:focusable="false" 

     android:layout_height="wrap_content"> 
     <com..........customModels.TextViewMedium 
      android:id="@+id/categoryTitle" 
      android:focusable="false" 
      android:layout_gravity="center_vertical" 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      android:gravity="center_vertical" 
      android:layout_marginRight="48dp" 
      android:textSize="18dp" 
      android:text="test text"/> 
    </LinearLayout> 
    <ImageView 
     android:id="@+id/item_folder_icon" 
     android:layout_width="36dp" 
     android:layout_height="36dp" 
     android:layout_marginLeft="4dp" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:src="@drawable/ic_folder"/> 
    <ImageView 
     android:id="@+id/item_folder_right_arrow" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_rightarow"/> 
    <View 
     android:id="@+id/item_divider" 
     android:layout_below="@id/item_layout" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@color/divider"/> 
    <LinearLayout 
     android:layout_below="@+id/item_divider" 
     android:id="@+id/main_menu_expandable_sublist_container" 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:visibility="gone" 
     android:layout_height="wrap_content"> 
     <com..........customModels.AnimatedExpandableListView 
      android:id="@+id/main_menu_expandable_sublist" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:divider="@color/divider" 
      android:childDivider="@color/divider" 
      android:transcriptMode="normal" 
      android:visibility="gone" 
      android:groupIndicator="@null" 
      android:background="@color/layouts_background"/> 
    </LinearLayout> 

</RelativeLayout> 

(subcats없이) 최종 제품의 샘플입니다 : 여기

은 확장 목록 항목의 샘플입니다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/item_container" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:focusable="false" 
    android:clickable="true" 
    android:background="@drawable/custom_background" 
    android:layout_height="wrap_content"> 
    <ImageView 
     android:id="@+id/item_folder_right_arrow" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_rightarow"/> 
    <LinearLayout 
     android:id="@+id/item_layout" 
     android:layout_width="match_parent" 
     android:focusable="false" 

     android:layout_height="match_parent"> 
     <com...........customModels.TextViewMedium 
      android:id="@+id/categoryTitle" 
      android:focusable="false" 
      android:layout_gravity="center_vertical" 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      android:gravity="center_vertical" 
      android:layout_marginRight="48dp" 
      android:textSize="18dp" 
      android:text="test text"/> 
    </LinearLayout> 
    <View 
     android:layout_below="@id/item_layout" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@color/divider"/> 
</RelativeLayout> 

은 구현하기가 쉽지 않다하지만 최종 결과는 매력처럼 작동))

+0

이렇게 xml에서 제쳐두고 이것은 어댑터의 코드일까요? –

+0

확장 가능한 recyclerview 항목입니다. –