我有一個gridview
,你可以在第一張圖片中看到。現在我想添加標題到gridview
的某個特定部分,如同第二張圖。我正在努力實現這一目標。如何在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;
}
ISIT解決????? –