开发者

Expandable lists using XML

开发者 https://www.devze.com 2023-03-15 20:57 出处:网络
My current project contains a list view with the contents bei开发者_开发知识库ng a string array defined in xml.

My current project contains a list view with the contents bei开发者_开发知识库ng a string array defined in xml.

setContentView(R.layout.contacts);
String[] peoples = getResources().getStringArray(R.array.contacts);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, peoples));
//uses the list_item.xml in the layout folder.
getListView().setTextFilterEnabled(true);

This works flawlessly as a very simple and quick company contact list that only requires xml modification to add new people ( i left out my unintelligent logic for the phone numbers, it's unimportant.)

But i want to improve this by using expandable lists for department, rank, etc. You can pack in a lot more information while keeping the display manageable this way.

The problem is i have yet to see any way to do expandable lists where the arrays for parents and children are xml defined string arrays. Any one got any links, suggestions, code, or bullets?


I'm either about to insult your intelligence or you're about to hit yourself on the head, but have you looked at ExpandableListViews?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号