鉴于从后不响应点击机器人 [英] view from back does not respond to click android

查看:127
本文介绍了鉴于从后不响应点击机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包括不同意见,其中可能会或可能不会是present一个的ImageButton(视情况)项的gridview的。我实现onItemClick网格内的每一个项目,但我也需要有一个敬酒显示出来时,信息按钮是present(和pressed)。一切工作正常,但事实上,它包含信息按钮的项目将不响应onItemClick了,他们只以信息图标是pressed回应。我怎样才能让这些项目作出相应的反应既可以点击信息按钮和其他领域?

I have a gridview with items consisting of different views, among which an ImageButton which may or may not be present (depending on the case). I implemented onItemClick for each item inside the grid, but I also need to have a toast showing up when the info button is present (and pressed). Everything worked fine, except the fact that the items which contain the info button will not respond to onItemClick anymore, they only respond to the info icon being pressed. How can I make those items respond accordingly both to click on the info button and on other areas?

下面是$ C $下onItemClick():

Here is the code for onItemClick():

@Override
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
        getDayStatus((Date) _monthVectorList.get(0).get(arg2));
        _listenerDateSelect.onDispatchDateSelect((Date) _monthVectorList.get(0).get(arg2)); 
}

和这里是对的ImageButton信息:

and here is the imageButton for Info:

<ImageButton
    android:layout_width="15dp"
    android:layout_height="15dp"
    android:id="@+id/tv_day_info"
    android:layout_gravity="center"
    android:gravity="right|center"
    android:layout_marginLeft="1dp"
    android:onClick="infoToast"
    android:focusable="false"
    />

另外,这里是$ C $下信息敬酒:

Also, here is the code for info toast:

public void infoToast(View view){
        Date date = (Date) view.getTag();
    List<String> dayDescription = getDayStatus(date);
    Context context = (Context) getApplicationContext();
    int duration = Toast.LENGTH_SHORT;
    CharSequence text = (String) dayDescription.get(2);

    Toast.makeText(context, text, duration).show();
    }

我试图将焦点设置关闭的ImageButton的,但它仍然无法正常工作。 我附上图片,以获得更好的描述的问题: http://oi42.tinypic.com/2rcxrv6。 JPG

I tried setting the focus off to the imageButton, but it still does not work. I attach an image to get a better depiction of the issue: http://oi42.tinypic.com/2rcxrv6.jpg

推荐答案

这增加的ImageButton的根布局

add this to root layout of ImageButton

android:descendantFocusability="blocksDescendants"

这篇关于鉴于从后不响应点击机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆