[英]Android: How to make child rows in ExpandableListView non-cklickable?
[英]How to make child in ExpandableListView a textbox instead of a list for Android?
所以我有一个ExpandableListView。 现在,我在父列表中有3个项目。 当我单击其中之一时,子列表(子列表会弹出)。 我想要的是一个文本框显示在下面而不是列表中。
我想为父母提供一个列表,但为孩子提供一个文本框。 我不确定该怎么做。 这是我现在的代码:
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。 不知道如何实现这一点。 任何帮助,不胜感激!
尝试仅在“ R.layout.child_row”中放置一个edittextview。 如果出现错误,则还要放置文本视图,但使其不可见。我希望这将解决问题
这非常简单,您应该创建一个名为:child_layout_row的布局,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent">
<EditText android:id="@+id/text_edit_child"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
而不是R.layout.child_row
,而是使用R.layout.child_layout_row
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.