gpt4 book ai didi

Android - ListView 禁用项目部分标题中的按下效果

转载 作者:太空宇宙 更新时间:2023-11-03 12:59:32 27 4
gpt4 key购买 nike

我有一个带有多个元素和部分标题的 listView。所有项目都有一个节标题,但仅在必要时显示。这里是可能项目的 xml 代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector_transparent"
android:paddingLeft="@dimen/padding_small"
android:paddingRight="@dimen/padding_small" >

<TextView
android:id="@+id/item_training_section_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/item_training_section_header_margin_top"
android:background="@drawable/list_selector_transparent"
android:paddingLeft="@dimen/padding_small"
android:textColor="@color/item_training_section_header_color"
android:textSize="@dimen/item_training_section_header_text_size"
android:textStyle="bold"
android:visibility="visible" />

<RelativeLayout
android:id="@+id/item_training_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/item_training_section_header"
android:background="@drawable/list_selector"
android:orientation="horizontal" >

<ImageView
android:id="@+id/item_training_logo"
android:layout_width="@dimen/item_training_image_width"
android:layout_height="@dimen/item_training_image_height"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/margin_small"
android:contentDescription="@string/image_description" />

<TextView
android:id="@+id/item_training_title_formation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="@dimen/margin_small"
android:layout_toRightOf="@id/item_training_logo"
android:textColor="@color/item_training_title_formation_color"
android:textSize="@dimen/item_training_title_formation_text_size" />
</RelativeLayout>

我用“android:clickable”和“android:descendantFocusability”尝试了几件事,但没有任何效果。你有什么主意吗 ?感谢您的回复?

最佳答案

所以,我找到了解决方案。这非常简单,但我不确定为什么:

我只是在 true 我的部分标题处插入可点击参数:

android:clickable="true"

这里是所有项目:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/padding_small"
android:paddingRight="@dimen/padding_small" >

<TextView
android:id="@+id/item_training_section_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:clickable="true"
android:layout_marginTop="@dimen/item_training_section_header_margin_top"
android:paddingLeft="@dimen/padding_small"
android:textColor="@color/item_training_section_header_color"
android:textSize="@dimen/item_training_section_header_text_size"
android:textStyle="bold"
android:visibility="visible" />

<RelativeLayout
android:id="@+id/item_training_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/item_training_section_header"
android:background="@drawable/list_selector"
android:orientation="horizontal" >

<ImageView
android:id="@+id/item_training_logo"
android:layout_width="@dimen/item_training_image_width"
android:layout_height="@dimen/item_training_image_height"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="@dimen/margin_small"
android:contentDescription="@string/image_description" />

<TextView
android:id="@+id/item_training_title_formation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="@dimen/margin_small"
android:layout_toRightOf="@id/item_training_logo"
android:textColor="@color/item_training_title_formation_color"
android:textSize="@dimen/item_training_title_formation_text_size" />
</RelativeLayout>

谁能解释一下这个解决方案?

关于Android - ListView 禁用项目部分标题中的按下效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13882613/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com