【发布时间】:2016-08-11 07:33:16
【问题描述】:
我在组项的ExpandableListView 中添加了EditText,之后当我单击组项时,不会出现包含子项的列表。可能是什么问题?在这种情况下是否可以扩展此列表?或者ExpandedListView的组项中禁止添加EditText?
适配器代码:
public class ClaimEqpExpandableListAdapter extends BaseExpandableListAdapter {
private Context _context;
public List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
public ClaimEqpExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
public ClaimEqpExpandableListAdapter(Context context, List<String> listDataHeader) {
this._context = context;
this._listDataHeader = listDataHeader;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.claim_explist_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
txtListChild.setText(childText);
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.size();
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.claim_eq_list_group, null);
// convertView = infalInflater.inflate(R.layout.claim_list_group, null);
}
TextView tvWorkNumber = (TextView) convertView
.findViewById(R.id.tvWorkNumber);
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.tvClaimWorkName);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
int displayPosition=groupPosition+1;
tvWorkNumber.setText(String.valueOf(displayPosition));
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public void updateData(List<String> groups,
HashMap<String, List<String>> children) {
this._listDataHeader = groups;
this._listDataChild = children;
}
}
claim_eq_list_group.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="@+id/tvWorkNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginTop="10dp"
android:text="1"
android:textSize="@dimen/doc_title_font_size" />
<TextView
android:id="@+id/tvClaimWorkName"
android:layout_width="match_parent"
android:layout_height="26dp"
android:layout_marginLeft="7dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/tvWorkNumber"
android:textSize="@dimen/doc_title_font_size" />
<EditText
android:id="@+id/tvClaimEquip"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_marginRight="60dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/tvClaimWorkName"
android:inputType="number"
android:textSize="@dimen/doc_title_font_size" />
</RelativeLayout>
claim_explist_item.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/lblListItem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
android:paddingTop="5dp"
android:textSize="17dip" />
</LinearLayout>
【问题讨论】:
-
请贴出代码...
-
@Lino 刚刚添加
-
试试这个:yourEditText.setFocusable(false);
标签: java android expandablelistview