LinearLayouts的Andr​​oid图库 [英] Android gallery of LinearLayouts

查看:73
本文介绍了LinearLayouts的Andr​​oid图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用画廊小部件创建LinearLayouts的画廊,他们每个人包含按钮。现在的问题是,虽然滚动或者点击的LinearLayout该按钮被pressed状态。我如何prevent呢?我希望它只是反应直接点击按钮。

感谢

//编辑:连code

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =260dip
    机器人:layout_height =WRAP_CONTENT
    机器人:填充=10dip>  <! - 在这里一些其他的东西 - >  <按钮风格=@风格/按钮
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_gravity =CENTER_HORIZONTAL
        机器人:文字=只是测试/>
< / LinearLayout中>


解决方案

我刚刚发现了同样的问题已经在这里问:<一href=\"http://stackoverflow.com/questions/3858220/gallery-adapterview-child-drawable-state\">Gallery/AdapterView儿童可绘制国家

重载集pressed的伎俩。

I'm using Gallery widget to create gallery of LinearLayouts, each of them containing a button. The problem is that while scrolling or clicking LinearLayout that button gets "pressed" state. How do I prevent it? I want it to react only to direct button clicks.

Thanks

// Edit: attached code

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

  <!-- some other things here -->

  <Button style="@style/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Just testing" />
</LinearLayout>

解决方案

I've just found out the same question has been asked here: Gallery/AdapterView Child Drawable State

Overriding setPressed did the trick.

这篇关于LinearLayouts的Andr​​oid图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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