Android gallery of LinearLayouts

谁说胖子不能爱 提交于 2019-12-11 07:04:38

问题


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>

回答1:


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

Overriding setPressed did the trick.



来源:https://stackoverflow.com/questions/7192417/android-gallery-of-linearlayouts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!