0

下面是我的 gridview 布局,当我在其布局上添加按钮时,它可以在没有按钮的情况下正常工作,它停止在 gridview 中选择 clickany 图像没有影响为什么/??gridview 有没有限制在其布局上不添加按钮???这是我的屏幕截图 imgur.com/jvGzpRP

        I'm changing from this:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:orientation="vertical" >

 <ImageView
    android:id="@+id/image2"
    android:layout_width="wrap_content"
    android:layout_height="70dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:padding="5dp"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

 <TextView
    android:id="@+id/title2"
    android:layout_width="90dp"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:paddingTop="10dp"
    android:textColor="#000" />

  </LinearLayout>

      To this:

  <LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >

 <ImageView
    android:id="@+id/image2"
    android:layout_width="fill_parent"
    android:layout_height="150dp"
    android:layout_weight="1"
    android:gravity="center_horizontal"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="2"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/title2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:gravity="center_vertical"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/title3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_vertical" />
 </LinearLayout>
  </LinearLayout>

   <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical" >

 <Button
    android:id="@+id/ButtonSendFeedback"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/roundshapebtn"
    android:text="Order Now"
    android:textColor="#ffffff"
    android:textSize="15pt" />
 </LinearLayout>







                    gridview = (GridView) findViewById(R.id.gridview3);
        cla = new CategoryListAdapter5(ProductList.this);
                    gridview.setAdapter(cla);




            public class CategoryListAdapter5 extends BaseAdapter {

private Activity activity;


private AQuery androidAQuery;


public CategoryListAdapter5(Activity act) {
    this.activity = act;
//  imageLoader = new ImageLoader(act);
}

public int getCount() {
    // TODO Auto-generated method stub
    return ProductList.Category_ID.size();
}

public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
}

public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    ViewHolder holder;
    androidAQuery = new AQuery(getcontext());
    if(convertView == null){
        LayoutInflater inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.viewitem3, null);
        holder = new ViewHolder();

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


    holder.txtText = (TextView) convertView.findViewById(R.id.title2);
    holder.txtText3 = (TextView) convertView.findViewById(R.id.title3);
    holder.imgThumb = (ImageView) convertView.findViewById(R.id.image2);

//  holder.txtText.setText(ProductList.Category_name.get(position));
    holder.txtText.setText(Html.fromHtml(ProductList.Category_name.get(position)));
    holder.txtText3.setText(Html.fromHtml(ProductList.Category_price.get(position)));

     androidAQuery.id(holder.imgThumb).image(ProductList.Category_image.get(position), true,  
     true);

    return convertView;
}
private Activity getcontext() {
    // TODO Auto-generated method stub
    return null;
}
static class ViewHolder {
    TextView txtText;
    TextView txtText3;
    ImageView imgThumb;
}

   }
4

1 回答 1

0
     <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F2F2F2" >



    <GridView
        android:id="@+id/img_grid"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/back_up_layout"
        android:layout_margin="5dp"
        android:choiceMode="multipleChoice"
        android:columnWidth="100dp"
        android:fastScrollEnabled="true"
        android:horizontalSpacing="10dp"
        android:numColumns="4"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10dp"
         />

    <LinearLayout
        android:id="@+id/back_up_layout"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:weightSum="2" >

        <Button
            android:id="@+id/back_up"
            android:layout_width="0dp"
            android:layout_height="40dp"
            android:layout_marginRight="5dp"
            android:layout_weight="1.65"
            android:background="@drawable/selector"
            android:singleLine="true"
            android:text="Backup Now (0)"
            android:textColor="#ffffff" />




    </LinearLayout>

</RelativeLayout>
于 2013-10-31T06:08:55.267 回答