在这里,我将一个布局膨胀到另一个具有列表视图的布局中
public class MyListAdapter extends ArrayAdapter<Certs>{
Context context;
public MyListAdapter(Context context, int resourceId,List<Certs> items){
super(context, resourceId, items);
this.context = context;
}
/*private view holder class*/
public class ViewHolder {
ImageView imageView;
TextView makeText;
ProgressBar mPB;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item_view, null);
holder = new ViewHolder();
holder.makeText = (TextView) convertView.findViewById(R.id.item_txtName);
holder.imageView = (ImageView) convertView.findViewById(R.id.item_icon);
holder.mPB = (ProgressBar) convertView.findViewById(R.id.progress);
//holder.mPB.getIndeterminateDrawable().setColorFilter(0xFF4b86bb, android.graphics.PorterDuff.Mode.DST);
convertView.setTag(holder);
} else{
holder = (ViewHolder) convertView.getTag();
}
Certs currentCert = myCerts.get(position);
holder.makeText.setText(currentCert.getName().toString());
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/calligraphic.ttf");
holder.makeText.setTypeface(face);
holder.imageView.setImageResource(currentCert.getIconID());
//holder.mPB.setProgress(10);
holder.mPB.setId(currentCert.getPbID());
return convertView;
}
}
通过这段代码,我可以扩展布局,但我不想在这里使用列表视图。我希望不同行中的多个图像和文本将显示在相同的线性布局上,而不使用列表视图。