expandablelistview的子列表项也用expandablelistview组成三级列表,但是三级列表显示不完整,高度不能自动调整,将layout_height设置为固定的一值(足够大)的时候可以全部显示出来,不管是设置为wrap_content还是fill_parent都不能正常显示像是发高度已经固定死了一样的,下面是getChildView()的代码:
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent)
{
if(childPosition < notSubsection[groupPosition]){
View view = View.inflate(context, R.layout.childview, null);
TextView textView = (TextView)view.findViewById(R.id.childTextView);
textView.setText(getChild(groupPosition, childPosition).toString());
view.findViewById(R.id.childImageView2).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_CALL,Uri.parse("tel:"+telephone[groupPosition][childPosition])));
view.findViewById(R.id.childImageView3).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_SENDTO,Uri.parse("smsto:"+telephone[groupPosition][childPosition])));
view.findViewById(R.id.childImageView4).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_SENDTO,Uri.parse("mailto:"+email[groupPosition][childPosition])));
return view;
}
else{
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);//设置宽度和高度
ExpandableListView expandableListView = new ExpandableListView(context);
SubsectionAdapter subsectionAdapter = new SubsectionAdapter(groupPosition,depSubsectionName[groupPosition].length, context);
expandableListView.setAdapter(subsectionAdapter);
expandableListView.setLayoutParams(lp);
return expandableListView;
}
求解???
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent)
{
if(childPosition < notSubsection[groupPosition]){
View view = View.inflate(context, R.layout.childview, null);
TextView textView = (TextView)view.findViewById(R.id.childTextView);
textView.setText(getChild(groupPosition, childPosition).toString());
view.findViewById(R.id.childImageView2).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_CALL,Uri.parse("tel:"+telephone[groupPosition][childPosition])));
view.findViewById(R.id.childImageView3).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_SENDTO,Uri.parse("smsto:"+telephone[groupPosition][childPosition])));
view.findViewById(R.id.childImageView4).setOnClickListener(new MyPictureOnClickListener(Intent.ACTION_SENDTO,Uri.parse("mailto:"+email[groupPosition][childPosition])));
return view;
}
else{
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);//设置宽度和高度
ExpandableListView expandableListView = new ExpandableListView(context);
SubsectionAdapter subsectionAdapter = new SubsectionAdapter(groupPosition,depSubsectionName[groupPosition].length, context);
expandableListView.setAdapter(subsectionAdapter);
expandableListView.setLayoutParams(lp);
return expandableListView;
}
求解???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货