public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
Kindergarten entity = list.get(position);
if (convertView != null && convertView.getId() == R.id.teacher_list) {
viewHolder = (ViewHolder) convertView.getTag();
} else {
viewHolder = new ViewHolder();
convertView = mInflater.inflate(R.layout.childavatar, null);
// int pHight = mgridView.getHeight();
// GridView.LayoutParams params = new GridView.LayoutParams(
// LayoutParams.MATCH_PARENT, pHight / 3);
//
AbsListView.LayoutParams param = new AbsListView.LayoutParams(
android.view.ViewGroup.LayoutParams.FILL_PARENT,
mgridView.getHeight()/3);
viewHolder.text_name = (TextView) convertView
.findViewById(R.id.childname);
viewHolder.imageIcon = (ImageView) convertView
.findViewById(R.id.childhead);
Resources r = Resources.getSystem();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, r.getDisplayMetrics());
Log.i("px", px+"");
convertView.setLayoutParams(param);
// viewHolder.imageIcon.setLayoutParams(new LinearLayout.LayoutParams((int)px, (int)px));
// viewHolder.imageIcon.setScaleType(ImageView.ScaleType.FIT_XY);
// viewHolder.parent_name1=(TextView)convertView.findViewById(R.id.parent1);
// viewHolder.parent_name2=(TextView)convertView.findViewById(R.id.parent2);
}
if(entity.getChildeavatar()!=null){
String tag = AppConfig.IMAGE_FILE+ entity.getChildeavatar();
if (tag.contains("?")) {// 截断?后的字符串,避免无效图片
tag = tag.substring(0, tag.indexOf("?"));
}
viewHolder.imageIcon.setTag(tag);
Drawable cachedImage = asyncImageLoader.loadDrawable(
ImageCacher.EnumImageType.Avatar, tag, new ImageCallback() {
public void imageLoaded(Drawable imageDrawable, String tag) {
Log.i("Drawable IN teacherAdapter", tag);
ImageView imageViewByTag = (ImageView) mgridView
.findViewWithTag(tag);
if (imageViewByTag != null && imageDrawable != null) {
imageViewByTag.setImageDrawable(imageDrawable);
} else {
try {
imageViewByTag
.setImageResource(R.drawable.jiazhangtouxiang);
} catch (Exception ex) {
}
}
}
});
if (cachedImage != null) {
viewHolder.imageIcon.setImageDrawable(cachedImage);
Log.i("setImg in method Check in", tag+"??");
}
else {
viewHolder.imageIcon.setBackgroundResource(R.drawable.jiazhangtouxiang);
Log.i("setImg in method Check in else", tag+"??");
}
}
viewHolder.text_name.setText(entity.getClassName());
Log.i("ChildName", entity.getClassName());
convertView.setTag(viewHolder);
return convertView;
自己顶一下,无法显示文字啊! 我已经 viewHolder.text_name.setText(entity.getClassName()); 了 而且,如果 去掉这句 convertView.setLayoutParams(param); 就又显示文字了! 崩溃了~但是我必须控制它显示的高度 确保全屏铺满啊!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。