所以我有一个ExpandableListView。现在我在父列表中有3个项目。当我点击其中一个时,子列表(子列表弹出)。我想要的是一个文本框显示在下面,而不是一个列表。如何让ExpandableListView中的孩子成为文本框而不是Android的列表?
我想要一个父级列表,但为孩子的文本框。我不知道如何做到这一点。这是我的代码现在:
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_assignment);
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
this,
createGroupList(), // Creating group List.
R.layout.group_row, // Group item layout XML.
new String[] { "Group Item" }, // the key of group item.
new int[] { R.id.row_name }, // ID of each group item.-Data under the key goes into this TextView.
createChildList(), // childData describes second-level entries.
R.layout.child_row, // Layout for sub-level entries(second level).
new String[] {"Sub Item"}, // Keys in childData maps to display.
new int[] { R.id.grp_child} // Data under the keys above go into these TextViews.
);
setListAdapter(expListAdapter); // setting the adapter in the list.
}catch(Exception e){
System.out.println("Errrr +++ " + e.getMessage());
}
}
//Create Headings of Assignment attributes
private List createGroupList() {
ArrayList result = new ArrayList();
//Create string array for Assignment Topic headings
String[] topics = {"1", "2", "3"};
//Iterate through array of names to lay them out correctly
for(int i = 0 ; i < 3 ; ++i) {
HashMap m = new HashMap();
m.put("Group Item", topics[i]); // the key and it's value.
result.add(m);
}
return (List)result;
}
@SuppressWarnings("unchecked")
private List createChildList() {
ArrayList result = new ArrayList();
for(int i = 0 ; i < 3 ; ++i) { // this -15 is the number of groups(Here it's fifteen)
/* each group need each HashMap-Here for each group we have 3 subgroups */
ArrayList secList = new ArrayList();
for(int n = 0 ; n < 3 ; n++) {
HashMap child = new HashMap();
child.put("Sub Item", "Sub Item " + n);
secList.add(child);
}
result.add(secList);
}
return result;
}
很显然,我创建一个的childList时,我希望孩子成为一个文本框。不知道如何实现这个寿命。任何帮助非常感谢!
有没有任何建议为你工作? – prolink007 2012-07-16 17:39:48