Android Gridview项对单击没有响应

Android Gridview项对单击没有响应,android,xml,gridview,Android,Xml,Gridview,对于这个问题,我试过所有类似的答案,但都没有用。我有一个嵌套在布局中的网格视图,上面有另外两个textview,我有一个自定义适配器,可以成功填充网格视图,但是我无法让网格项响应单击。我的XML如下所示,带有点击式侦听器的一段代码 Grid_layout.xml <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

对于这个问题,我试过所有类似的答案,但都没有用。我有一个嵌套在布局中的网格视图,上面有另外两个textview,我有一个自定义适配器,可以成功填充网格视图,但是我无法让网格项响应单击。我的XML如下所示,带有点击式侦听器的一段代码

Grid_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_parent_rounded_corner"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/ll_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/feed_item_margin"
    android:layout_marginRight="@dimen/feed_item_margin"
    android:layout_marginTop="@dimen/feed_item_margin"
    android:orientation="vertical"
    android:paddingBottom="5dp"
    android:paddingTop="5dp" >

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/profileOfffer"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:scaleType="fitCenter" >
    </com.android.volley.toolbox.NetworkImageView>

    <LinearLayout
        android:id="@+id/bottom"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/names"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="@dimen/feed_item_profile_name"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/price"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#70B440"
            android:textSize="@dimen/feed_item_profile_name" />

    </LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F3"
android:orientation="vertical" 
android:descendantFocusability="blocksDescendants">

<TextView
    android:id="@+id/user_salute_"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:paddingTop="10dp"
    android:text="@string/header_share"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#000000" />

<TextView
    android:id="@+id/points_"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:paddingBottom="10dp"
    android:paddingTop="10dp"
    android:text="@string/sub_header_share"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#000000" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:contentDescription="@string/app_name"
    android:drawableLeft="@drawable/sale"
    android:paddingBottom="10dp"
    android:text="@string/offers"
    android:textColor="#3E9DE1" />

<GridView
    android:id="@+id/gridview_"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:columnWidth="100dp"
    android:gravity="center"
    android:horizontalSpacing="10dp"
    android:numColumns="2"
    android:scrollbars="none"
    android:stretchMode="columnWidth"
    android:verticalSpacing="10dp" />

Grid_layout.xml中的滚动视图使用事件。因此,请处理它。

单击某个项目时,您预计会发生什么情况?我现在已经删除了逻辑,但出于测试目的,我记录了位置,这不会发生。您可以发布getView方法吗?@Jerick我再次更新了Grid\u home\u item.xml,请。
 gridView.setAdapter(adapter);
            gridView.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id)        {
 //Fragment transaction logic here
 Log.i("Test","Clicked position"+position);
} });
   @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    View vi=convertView;

    if (convertView == null){
        vi = inflater.inflate(R.layout.grid_home_item, parent, false);
    holder = new ViewHolder();
    holder.name = (TextView)vi.findViewById(R.id.names);
    holder.information = (TextView)vi.findViewById(R.id.price);
    holder.Pic = (NetworkImageView)vi.findViewById(R.id.profileOfffer);

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

    Offers_Item item = offersItems.get(position);
    holder.name.setFocusable(false);
    holder.name.setText(item.getOfferName());

    holder.Pic.setImageUrl(item.getImage(), imageLoader);
    holder.Pic.setFocusable(false);

  if (!TextUtils.isEmpty(item.getOfferValue())  && !(item.getOfferValue().contentEquals("0")) &&!(item.getOfferValue().contentEquals("0.00"))) {
        holder.information.setText("NOW! KES. "+item.getOfferValue());
        holder.information.setFocusable(false);
        holder.information.setVisibility(View.VISIBLE);
    } else {
        holder.information.setVisibility(View.GONE);
        holder.information.setFocusable(false);
    }




    return vi;
}