私のギャラリーの各アイテムはカスタムビューです。子のビューの1つはgridViewです。ギャラリーをスクロールしているときはすべて正常に機能しますが、gridViewをタッチしてもスクロールしません。説明するのは難しいですが、誰かが私を理解してくれることを願っています!カスタムビューの任意の部分をタッチしてスクロールすると、スクロールがトリガーされると思いますか?それとも、imageViewだけがスクロールをトリガーしますか?
public View getView(int position, View convertView, ViewGroup parent) {
final SubProduct subProduct=subProducts.get(position);
int quantity=subProduct.getQuantity();
int size=subProduct.getSizes().get(0).getWidth();
String productName=subProduct.getProductName();
int productPrice=subProduct.getSizes().get(0).getPrice();
int columnWidth = 0;
View view=convertView;
if (view==null){
holder=new SubProductHolder();
//The main container
holder.myLinearLayout= new LinearLayout(this.myContext);
holder.myLinearLayout.setOrientation(1);//vertical
//The custome button
LayoutInflater inflater = (LayoutInflater)
myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v=(View)inflater.inflate(R.layout.custom_sub_product_layout, null);
LinearLayout btnLayout = (LinearLayout)v.findViewById(R.id.customSunProductButtonLayout);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(PRODUCT_BOTTUN_WIDTH,PRODUCT_BOTTUN_HEIGHT);
btnLayout.setLayoutParams(llp);
tvSubProductDescription=(TextView)v.findViewById(R.id.tvSubProductDescription);
tvSubProductPrice=(TextView) v.findViewById(R.id.tvSubProductPrice);
holder.btnProduct=btnLayout;
holder.btnProduct.setGravity(Gravity.CENTER);
holder.TvLinearLayout= new LinearLayout(this.myContext);
holder.TvLinearLayout.addView(holder.btnProduct);
//frame
holder.image = new ImageView(this.myContext);
holder.image.setBackgroundColor(Color.WHITE);
LinearLayout.LayoutParams llp2 = new LinearLayout.LayoutParams(FRAME_WIDTH,FRAME_WIDTH);
holder.image.setLayoutParams(llp2);
//grid
holder.grid=new GridView(myContext);
//the number of rows is the round number of quantity sqaure
int numberOfColomns=(int) Math.floor((int) Math.sqrt(quantity));
holder.grid.setNumColumns(numberOfColomns);
holder.grid.setLayoutParams(new RelativeLayout.LayoutParams(PRODUCT_PICTURE_WIDTH,PRODUCT_PICTURE_WIDTH));
}else{
holder=(SubProductHolder)view.getTag();
}
//set text in description tv
tvSubProductDescription.setText(quantity+" "+productName+" "+size+"X"+size);
tvSubProductPrice.setText("$"+productPrice);
//set the grid
holder.grid.setAdapter(new emptySquaresAdapter(quantity,myContext,columnWidth,columnHeight));
holder.relativeGridLayout=new RelativeLayout(myContext);
holder.relativeGridLayout.addView(holder.image);
holder.relativeGridLayout.addView(holder.grid);
//set button and picture to layout
holder.myLinearLayout.addView(holder.relativeGridLayout);
holder.myLinearLayout.addView(holder.TvLinearLayout);
return holder.myLinearLayout;
}
static class SubProductHolder
{
ImageView image;
GridView grid;
RelativeLayout relativeGridLayout;
LinearLayout btnProduct;
LinearLayout TvLinearLayout;
LinearLayout myLinearLayout;
}