Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
仅长按ClickListner子项滑动在android中不显示_Android_Onlongclicklistener - Fatal编程技术网

仅长按ClickListner子项滑动在android中不显示

仅长按ClickListner子项滑动在android中不显示,android,onlongclicklistener,Android,Onlongclicklistener,您好,在下面的代码中,cardview长按想要禁止父触摸事件,想要显示要从右侧拉出的滑动编辑和共享选项。下面的代码包含cardview,右侧包含编辑/共享 当我长按来自家长的cardview时,我不允许水平滚动查看,但使用下面的代码,滑动选项不显示 holder.cardView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onL

您好,在下面的代码中,cardview长按想要禁止父触摸事件,想要显示要从右侧拉出的滑动编辑和共享选项。下面的代码包含cardview,右侧包含编辑/共享

当我长按来自家长的cardview时,我不允许水平滚动查看,但使用下面的代码,滑动选项不显示

 holder.cardView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                holder.sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
                holder.sample1.setDragEdge(SwipeLayout.DragEdge.Right);
                   v.getParent().requestDisallowInterceptTouchEvent(true);


                return true;
            }
        });
layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/back_blue"
    android:id="@+id/contact_card"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_anchorGravity="center"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/card_details">



            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:id="@+id/cards"
                android:background="@color/back_blue">

                <com.daimajia.swipe.SwipeLayout
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/sample1">

                <LinearLayout
                    android:id="@+id/bottom_wrapper"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:weightSum="4"
                    android:orientation="vertical">


                    <ImageView
                        android:id="@+id/share"
                        android:src="@drawable/share"
                        android:layout_width="70dp"
                        android:paddingLeft="15dp"
                        android:layout_weight="2"
                        android:background="@color/back_blue"
                        android:paddingRight="15dp"
                        android:layout_height="match_parent" />
                    <View
                        android:layout_width="fill_parent"
                        android:layout_height="2dp"
                        android:background="@color/slivergray"
                        android:layout_below="@id/share"/>
                    <ImageView
                        android:id="@+id/edit"
                        android:src="@drawable/ic_launcher"
                        android:layout_width="70dp"
                        android:background="@color/back_blue"
                        android:layout_weight="2"
                        android:paddingLeft="15dp"
                        android:paddingRight="15dp"
                        android:layout_height="match_parent" />

                </LinearLayout>

                <androidx.cardview.widget.CardView
                    android:id="@+id/cardView"
                    android:layout_width="350dp"
                    android:layout_height="wrap_content"
                    app:cardBackgroundColor="@color/slivergray"
                    app:cardCornerRadius="5dp"
                    app:cardElevation="4dp"
                    app:cardUseCompatPadding="true">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:background="@color/White">

                        <TextView
                            android:id="@+id/potential_name"
                            style="@style/Base.TextAppearance.AppCompat.Subhead"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/names"
                            android:paddingLeft="16dp"
                            android:layout_marginTop="3sp"
                            android:text="Potential Name"
                            android:textStyle="bold"
                            android:paddingRight="16dp"
                            android:textColor="@color/gray"
                            android:textSize="18sp"/>

                        <TextView
                            android:id="@+id/account_name"
                            style="@style/Base.TextAppearance.AppCompat.Subhead"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/potential_name"
                            android:paddingLeft="16dp"
                            android:text="Account Name"
                            android:textStyle="bold"
                            android:paddingRight="16dp"
                            android:textColor="@color/gray"
                            android:textSize="15sp"/>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:id="@+id/assigned"
                            android:layout_below="@+id/account_name"
                            android:weightSum="3">

                            <TextView
                                android:id="@+id/text_ass"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:layout_below="@+id/bill_city"
                                android:paddingLeft="16dp"
                                android:paddingRight="16dp"
                                android:text="Assigned"
                                android:textColor="@color/gray"
                                android:textSize="15sp" />
                            <TextView
                                android:id="@+id/assigned_to"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/text_spec"
                                android:layout_weight="2"
                                android:textColor="@color/gray"
                                android:textSize="15sp"/>

                        </LinearLayout>


                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:id="@+id/streets"
                            android:layout_below="@+id/assigned"
                            android:weightSum="3">

                            <TextView
                                android:id="@+id/text_spec"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:layout_below="@+id/bill_city"
                                android:paddingLeft="16dp"
                                android:paddingRight="16dp"
                                android:text="Contact"
                                android:textColor="@color/gray"
                                android:textSize="15sp" />
                            <TextView
                                android:id="@+id/contact_name"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/text_spec"
                                android:layout_weight="2"
                                android:textColor="@color/gray"
                                android:textSize="15sp"/>

                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:id="@+id/citys"
                            android:weightSum="3"
                            android:layout_below="@+id/streets">

                            <TextView
                                android:id="@+id/text_city"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/citys"
                                android:paddingLeft="16dp"
                                android:text="Location"
                                android:paddingRight="16dp"
                                android:layout_weight="1"
                                android:textColor="@color/gray"
                                android:textSize="15sp"
                                />
                            <TextView
                                android:id="@+id/location"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/text_city"
                                android:layout_weight="2"
                                android:textColor="@color/gray"
                                android:textSize="15sp"/>

                        </LinearLayout>


                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:id="@+id/items"
                            android:weightSum="3"
                            android:layout_below="@+id/citys">

                            <TextView
                                android:id="@+id/text_district"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/bill_district"
                                android:paddingLeft="16dp"
                                android:paddingRight="16dp"
                                android:text="Product"
                                android:layout_weight="1"
                                android:textColor="@color/gray"
                                android:textSize="15sp" />
                            <TextView
                                android:id="@+id/item_name"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/text_district"
                                android:layout_weight="2"
                                android:text="product"
                                android:paddingRight="16dp"
                                android:textColor="@color/gray"
                                android:textSize="15sp"/>
                        </LinearLayout>


                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:id="@+id/amounts"
                            android:weightSum="3"
                            android:layout_below="@+id/items"
                            android:layout_marginBottom="4dp">

                            <TextView
                                android:id="@+id/text_total"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/bill_district"
                                android:layout_weight="1"
                                android:text="Value(Qty)"
                                android:paddingLeft="16dp"
                                android:textColor="@color/gray"
                                android:textSize="15sp"
                                />
                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:weightSum="3"
                                android:paddingLeft="2dp">
                            <TextView
                                android:id="@+id/amount"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/text_total"
                                android:text="@string/Rs"
                                android:layout_weight="1"
                                android:textColor="@color/gray"
                                android:textSize="15sp"/>

                            <TextView
                                android:id="@+id/text_qty"
                                style="@style/Base.TextAppearance.AppCompat.Subhead"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/salutations"
                                android:layout_weight="1"
                                android:text="qty"
                                android:textColor="@color/gray"
                                android:textSize="15sp"
                                />

                                <TextView
                                    android:id="@+id/win_prob"
                                    android:layout_width="50dp"
                                    android:layout_height="wrap_content"
                                    android:text="30%"
                                    android:textColor="@color/White"
                                    android:layout_weight="1"
                                    android:layout_marginLeft="52dp"
                                    android:layout_gravity="center"
                                    android:gravity="center"
                                    android:layout_alignParentRight="true"
                                    android:layout_alignParentTop="true"
                                    />

                            </LinearLayout>


                        </LinearLayout>



                        <View
                            android:layout_width="fill_parent"
                            android:layout_height="2dp"
                            android:background="@color/slivergray"
                            android:layout_below="@id/amounts"/>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:weightSum="2"
                            android:layout_below="@id/amounts">


                                <TextView
                                    android:id="@+id/potential_no"
                                    style="@style/Base.TextAppearance.AppCompat.Subhead"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_below="@+id/account_name"
                                    android:paddingLeft="16dp"
                                    android:text="Potenial No."
                                    android:layout_weight="1"
                                    android:textStyle="bold"
                                    android:textColor="@color/gray"
                                    android:textSize="15sp"/>
                                <Button
                                    android:id="@+id/pdf"
                                    style="@style/Base.Widget.AppCompat.Button.Borderless"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:text="View QUOTE"
                                    android:layout_weight="1"
                                    android:inputType="text"
                                    android:textColor="@color/password"
                                    android:textSize="15sp"
                                    android:textStyle="bold" />
                            </LinearLayout>
                    </RelativeLayout>
                </androidx.cardview.widget.CardView>
                </com.daimajia.swipe.SwipeLayout>



            </LinearLayout>



        </LinearLayout>


    </FrameLayout>



</RelativeLayout>