내가 ExpandableListView
로 최근에 수행 한 것입니다. 그것은 매우 쉽습니다.
그것은 지금까지 안드로이드에서 본 가장 큰 생성자 중 하나입니다.
ExpandableListView
으로 레이아웃을 만듭니다.
<LinearLayout>
<ExpandableListView>
<!-- Set the properties, if you need to see them, let me know. -->
</ExpandableListView>
</LinearLayout>
지금 몇 가지보기에서 레이아웃을 사용합니다.
public void onCreate() {
ExpandableListView example = findViewById(/* The id of the expandable list view */);
example.setAdapter(
new SimpleExpandableListAdapter(
/* the context */,
/* the map of parents/groups */,
/* the layout to map the parents/groups to */,
/* the key to search for in the parents/groups map */,
/* the id of the textview inside the layout to map the parent/group to */,
/* the map of children */,
/* the layout to map the children to */,
/* the key to search for in the children map */,
/* the id of the textview inside the layout to map the children to */)
)
}
는 다른 어댑터를 사용할 수 있습니다, 그러나 이것은 가장 기본적인 것입니다.
기본적으로 developer website을 살펴보십시오. 이 example도 다소 도움이되었지만 개발자 웹 사이트는 먼 길을 간다.
궁금한 점이 있으면 알려주십시오.
는
그가() createGroupList를 넣어 UP 따릅니다. 이것은 그가 주석을 달았던 기능이었던 것 같습니다. 정확히이게 뭐야?
그는 기본적으로 그 기능에 HashMaps
의 List
를 생성하고 생성 된 객체를 반환합니다. 예, 그런 식으로해야합니다. 코드를 좀 더 깨끗하게 유지하는 데 도움이됩니다.
또한 이러한 목록은 어쨌든 더 크게 만들 수 있습니다.
자녀 및 그룹을 표시하는 TextView
을 수정하십시오. xml
레이아웃의 View
에 패딩을 추가합니다. dp
만 조정하면됩니다. textSize
을 늘리거나 아래에 표시된 것처럼 style
을 추가 할 수 있습니다.
<TextView
android:id="@+id/groupTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Medium"
android:paddingLeft="50dp"
android:paddingTop="25dp"
android:paddingBottom="25dp"/>
나는 내가 그들을 내가 (텍스트를 추가 할 수있는 텍스트 상자가되고 싶어요, 상위 그룹이 나열되고 싶어하지만, 에 하위 그룹이 하위 목록이 될 싶지 않는 어떤 I로부터 잡아 그물). 목록보다는 어린이 텍스트 상자를 어떻게 만들 수 있습니까?
아마도이 상황을 위해 Adapter
을 만들어야 할 것입니다. BaseExpandableListAdapter
을 확장해야합니다. 나는 틀릴 수도 있고, 더 쉬운 방법이 있을지도 모른다. .. 그러나 나는 사람을 의식하지 않고있다.
추가 FOLLOW UP
당신이 무슨 뜻인지 확실하지. 하위 목록 에 입력 된 텍스트는 child.put ("Sub Item", "test") 코드의이 라인에옵니다. 나는 할 수있다 내가 "테스트"가 아니라 "테스트"라고하는 곳에 원하는 텍스트를 둬 모든 부모 목록 아래에 올라온다.
createChildList
은 List<ArrayList<HashMap<String, String>>>
을 반환해야합니다.
귀하의 createChildList
같은 것을 보일 것입니다 :
private List<ArrayList<HashMap<String, String>>> createChildList(int maxValue) {
ArrayList<ArrayList<HashMap<String, String>>> groupList =
new ArrayList<ArrayList<HashMap<String, String>>>();
for (int i = 0; i <= maxValue; i++) {
ArrayList<HashMap<String, String>> childList =
new ArrayList<HashMap<String, String>>();
for (int j = 0; j <= maxValue; j++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("Sub Item", "test: " + String.valueOf(j));
childList.add(map);
}
groupList.add(childList);
}
return groupList;
}
가 작동하는지 알려줘합니다.
ExpandableListView와 같이 사용하는 것이 좋습니다. – kcoppock
가시성 플래그를 사용할 수 없습니까? – Jin
ExpandableListView 내가 뭘 찾고, 더 좋은 튜토리얼이나 샘플 수 있습니다? 나는 그들을 찾아내는 데 어려움을 겪고있다. – jacosta