相关疑难解决方法(0)

Android:在linearlayout内的gridview的空白处检测点击事件

我有以下问题.我有一个GridView内部LinearLayout如下图所示.我想在用户点击GridView图像中的空白区域时检测点击事件,我想要的位置是红色区域,也是绿色区域内.

但我有以下问题.

  1. 如果我添加onClickListenerGridView:错误,因为适配器不能添加Click事件.
  2. 如果我添加onItemClickListenerGridView:我只是可以检测存在的项目(在图像中的白框)
  3. 如果我添加onClickListener,LinearLayout我只能检测绿色区域上的点击事件,而不是红色区域.

那么我该如何解决上述问题呢.

@Edit:我的布局看起来像:

<LinearLayout>
  <GridView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢 :)

在此输入图像描述

android

8
推荐指数
1
解决办法
5850
查看次数

通过视图android传递点击事件

我有框架布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp" >

<LinearLayout
    android:id="@+id/widgetView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_margin="10dp"
    android:gravity="center" >
</LinearLayout>

<LinearLayout
    android:id="@+id/widgetOverlayFrame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false" >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

第一个布局包含窗口小部件布局,第二个布局是透明的,并且接收onLongClick用于拖动方法.这有效,问题是当我想要与窗口小部件交互时,点击某些内容,点击事件由overlayFrame拍摄.如何将click事件通过overlayFrame传递给widgetView?

编辑:

现在我正在尝试将GestureLister附加到overlayFrame LinearLayout,以某种方式看到代表单击和长按的MotionEvent之间的区别.我面临的问题是,手势监听器中的OnLongPress总是被调用,无论我做什么,单击还是长按.

这种行为有解释吗?TNX!

android click

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×2

click ×1