私はgridview
を持っています(第1写真参照)。今度は、gridview
の特定の部分に2番目の画像のようにヘッダーを追加します。私はこれを達成するために苦労しています。Gridviewでヘッダーを作成するには?
このビューを達成する方法については、私には分かりません。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
holder = null;
Product productItem = (Product) productList.get(position);
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(R.layout.products_grid_item_layout, parent, false);
holder = new ViewHolder();
holder.productImage = (ImageView) row.findViewById(R.id.productImage);
holder.productImageClone = (ImageView) row.findViewById(R.id.productImageClone);
holder.detailsIcon = (ImageView) row.findViewById(R.id.detailsIcon);
holder.productTitle = (TextView) row.findViewById(R.id.productTitle);
holder.productSubTitle = (TextView) row.findViewById(R.id.productSubTitle);
holder.productQuantity = (TextView) row.findViewById(R.id.productQuantity);
holder.priceDollar = (TextView) row.findViewById(R.id.priceDollar);
holder.priceCent = (TextView) row.findViewById(R.id.priceCent);
holder.productCount = (TextView) row.findViewById(R.id.productCount);
holder.productGridLayout = (RelativeLayout) row.findViewById(R.id.productGridLayout);
row.setTag(holder);
} else {
holder = (ViewHolder) row.getTag();
}
String price = productItem.getPrice().toString();
String[] pricearray;
pricearray = price.split("\\.");
holder.productTitle.setText(productItem.getTitle().toString());
holder.productSubTitle.setText(productItem.getSubtitle().toString());
holder.productQuantity.setText(productItem.getVolume().toString());
holder.priceDollar.setText(pricearray[0]+".");
holder.priceCent.setText(pricearray[1]);
if(productItem.getInCart()) {
holder.productCount.setVisibility(View.VISIBLE);
holder.productCount.setText(productItem.getVolume());
}
Picasso.with(context)
.load(productItem.getImageUrl())
.placeholder(R.drawable.favourites)
.error(R.drawable.favourites)
.into(holder.productImage);
Picasso.with(context)
.load(productItem.getImageUrl())
.placeholder(R.drawable.favourites)
.error(R.drawable.favourites)
.into(holder.productImageClone);
urlSlug = productItem.getUrlSlug();
holder.detailsIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int position = currentGridView.getPositionForView(v);
Log.e("grid position", position+"");
Intent productDetailIntent = new Intent(context,ProductDetailActivity.class);
productDetailIntent.putExtra("url_slug", productList.get(position).getUrlSlug());
context.startActivity(productDetailIntent);
}
});
return row;
}
を使用することができます????? –