5

ビューをどのように膨らませて、の子ビューのリストに追加しますLinearLayoutか?

4

2 に答える 2

0
public class SearchResultAdapter extends BaseAdapter {

private Activity activity;
private ArrayList<SearchResultInfo> ChoseInfo;
private static LayoutInflater inflater=null;
public SearchResultImageLoader imageLoader; 

public SearchResultAdapter(Activity a, ArrayList<SearchResultInfo> ChoseInfo) {
    activity = a;
   this.ChoseInfo=ChoseInfo;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new SearchResultImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return ChoseInfo.size();
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public static class ViewHolder{
    public TextView PriceValue;
    public ImageView image;
    public TextView LikeValue;
    public TextView LikeName;

}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    ViewHolder holder;
    if(convertView==null){

        vi = inflater.inflate(R.layout.searchresult_showlayout_item, null);
        holder=new ViewHolder();
        holder.PriceValue=(TextView)vi.findViewById(R.id.priceValue);
        holder.image=(ImageView)vi.findViewById(R.id.clothimage);
        holder.LikeName=(TextView)vi.findViewById(R.id.LikeName);
        holder.LikeValue=(TextView)vi.findViewById(R.id.LikeValue);


        vi.setTag(holder);
    }
    else
        {
          holder=(ViewHolder)vi.getTag();
        }






    holder.PriceValue.setText(ChoseInfo.get(position).Price);
    holder.LikeValue.setText(ChoseInfo.get(position).LikeNum);
    holder.image.setTag(ChoseInfo.get(position).BitmapPath);
    imageLoader.DisplayImage(ChoseInfo.get(position).BitmapPath, activity, holder.image);
    holder.image.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //这里以后要进行传值
             Intent intent =new Intent();
             intent.setClass(getDialogContext(activity), SearchDetailActivity.class);
             intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
             getDialogContext(activity).startActivity(intent);
        }
    });


    return vi;
}
于 2011-09-01T12:59:43.767 に答える