Android(本机 java)-滑动抽屉-内容(图像视图和复选框)单击事件未触发

发布于 2024-12-27 05:50:42 字数 4233 浏览 2 评论 0原文

在其中一个项目中,我们有一个从底部滑动的面板。用户可以在其中选择复选框并单击面板内的图像。所以我在相对布局中添加了一个滑动抽屉组件。顶部视图将包含列表视图,底部视图将是一个滑动抽屉。

我们有滑动组件的手柄和内容部分。在内容中我添加了一个复选框和图像视图。当用户单击其中任何一个时,我想监听这些事件。我可以监听滑动抽屉事件,但不能监听其他两个单击事件。

我是否错过了监听滑动抽屉内容部分内事件的任何内容。我尝试在布局 xml 中将 clickable 属性添加为 true 。但结果还是一样。

我在谷歌搜索,但找不到解决方案。

如果我遗漏了什么,请告诉我。

<SlidingDrawer android:id="@+id/slidingDrawer1" android:layout_width="match_parent" 
                android:layout_height="wrap_content" android:handle="@+id/handle" android:content="@+id/content"
                android:animateOnClick="true" android:padding="15dp" android:topOffset="250dp" android:allowSingleTap="true"
                >
                <LinearLayout android:layout_width="match_parent"
                    android:layout_height="wrap_content" >

                    <LinearLayout android:layout_width="match_parent" android:layout_height="50dp"
                        android:id="@+id/handle" android:background="@drawable/popbg" android:paddingLeft="20dp"
                        android:paddingTop="20dp" android:paddingRight="20dp">
                        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                android:text="text1" android:textColor="#000000"
                                android:layout_weight="1"/>
                        <ImageView 
                            android:id="@+id/elrattSlidingIcon"
                            android:layout_width="wrap_content" android:layout_height="wrap_content"
                            android:src="@drawable/non_expand" android:layout_gravity="right"/>    
                    </LinearLayout>

                    <LinearLayout android:layout_width="match_parent"
                        android:layout_height="80dp"
                        android:gravity="center_horizontal" android:orientation="vertical"
                        android:id="@+id/content" android:paddingLeft="15dp" android:paddingRight="14dp"
                        android:clickable="true">
                        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
                            android:gravity="top" android:padding="0dp"
                            android:clickable="true">
                            <LinearLayout android:layout_width="match_parent"
                                android:layout_height="match_parent" android:gravity="center_horizontal"
                                android:paddingTop="15dp" android:orientation="vertical"
                                android:background="@drawable/bg_elratt">
                                <ImageView android:id="@+id/elrattListBtmBtn"
                                    android:layout_width="match_parent" android:layout_height="wrap_content"
                                    android:src="@drawable/skickaintr_ov" android:clickable="true"/>
                                <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
                                    android:orientation="horizontal" android:paddingLeft="50dp" android:paddingRight="50dp"
                                    android:paddingTop="10dp">
                                    <CheckBox android:id="@+id/usrOption" android:layout_width="0dp" android:layout_height="wrap_content"
                                        android:layout_weight="0.2" android:button="@drawable/checkbox_selector" android:tag="1"
                                        android:clickable="true"/>
                                    <TextView android:layout_width="0dp" android:layout_height="match_parent"
                                        android:text="test2" android:singleLine="false"
                                        android:layout_weight="0.8"/>
                                </LinearLayout>                                 
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>

                </LinearLayout>

            </SlidingDrawer>

提前致谢, 问候 斯里尼

In one of the project,we have a sliding panel from the bottom. In which user can choose the checkbox and click the image inside the panel. so i have added a sliding drawer component inside the relative layout. Top view will contain, listview and the bottom it will be a slidingdrawer.

We have the handle and content part for the sliding component. Inside the content i have added a checkbox and imageview. I want to listen for those events when user clicks any one of those. I can able to listen for teh sliding drawer events but not the other two click events.

DO i miss anything for listening of events inside content part in the sliding drawer. I tried by adding clickable property to true in layout xml. But still the same result.

I searched in google, but not able to find the solution.

Please let me know, if i am missing anything.

<SlidingDrawer android:id="@+id/slidingDrawer1" android:layout_width="match_parent" 
                android:layout_height="wrap_content" android:handle="@+id/handle" android:content="@+id/content"
                android:animateOnClick="true" android:padding="15dp" android:topOffset="250dp" android:allowSingleTap="true"
                >
                <LinearLayout android:layout_width="match_parent"
                    android:layout_height="wrap_content" >

                    <LinearLayout android:layout_width="match_parent" android:layout_height="50dp"
                        android:id="@+id/handle" android:background="@drawable/popbg" android:paddingLeft="20dp"
                        android:paddingTop="20dp" android:paddingRight="20dp">
                        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                android:text="text1" android:textColor="#000000"
                                android:layout_weight="1"/>
                        <ImageView 
                            android:id="@+id/elrattSlidingIcon"
                            android:layout_width="wrap_content" android:layout_height="wrap_content"
                            android:src="@drawable/non_expand" android:layout_gravity="right"/>    
                    </LinearLayout>

                    <LinearLayout android:layout_width="match_parent"
                        android:layout_height="80dp"
                        android:gravity="center_horizontal" android:orientation="vertical"
                        android:id="@+id/content" android:paddingLeft="15dp" android:paddingRight="14dp"
                        android:clickable="true">
                        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
                            android:gravity="top" android:padding="0dp"
                            android:clickable="true">
                            <LinearLayout android:layout_width="match_parent"
                                android:layout_height="match_parent" android:gravity="center_horizontal"
                                android:paddingTop="15dp" android:orientation="vertical"
                                android:background="@drawable/bg_elratt">
                                <ImageView android:id="@+id/elrattListBtmBtn"
                                    android:layout_width="match_parent" android:layout_height="wrap_content"
                                    android:src="@drawable/skickaintr_ov" android:clickable="true"/>
                                <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
                                    android:orientation="horizontal" android:paddingLeft="50dp" android:paddingRight="50dp"
                                    android:paddingTop="10dp">
                                    <CheckBox android:id="@+id/usrOption" android:layout_width="0dp" android:layout_height="wrap_content"
                                        android:layout_weight="0.2" android:button="@drawable/checkbox_selector" android:tag="1"
                                        android:clickable="true"/>
                                    <TextView android:layout_width="0dp" android:layout_height="match_parent"
                                        android:text="test2" android:singleLine="false"
                                        android:layout_weight="0.8"/>
                                </LinearLayout>                                 
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>

                </LinearLayout>

            </SlidingDrawer>

Thanks in Advance,
Regards
Srini

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我要还你自由 2025-01-03 05:50:42

我发现问题出在哪里了。不确定这是否正确。但这对我有用。

我删除了滑动抽屉组件后的直接线性布局。我将其添加为包装层。之后我就可以正常收听事件而无需任何其他更改。它像往常一样工作。

谢谢

问候

斯里尼瓦桑

I found where the problem is. Not sure whether this is the correct one. But it works for me.

I removed the immediate linearlayout after slidingdrawer component. Which i have added as a wrapper layer. After this i am able to listen to the events normally without any other changes. It was working as usual.

Thanks

Regards

Srinivasan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文