小编pra*_*kla的帖子

在Recyler视图中多次调用onClick

我想要处理回收器视图中的事件 - :

class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {

        private ClickListener clickListener;
        private GestureDetector gestureDetector;

        public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final ClickListener clickListener){

            this.clickListener = clickListener;
            gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener(){
                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    return true;
                }

                @Override
                public void onLongPress(MotionEvent e) {
                   View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
                    if(child!=null && clickListener!=null)
                    {
                        clickListener.onLongClick(child, recyclerView.getChildPosition(child));
                        Log.i("TAG", "Radhe handling LongPress ");
                    }
                }
            });
        }

        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

            View child = rv.findChildViewUnder(e.getX(), e.getY()); …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

1
推荐指数
1
解决办法
1743
查看次数

Recycler View不填充宽度

我有一个回收站视图,其中我显示自定义行但行没有填充宽度.我添加了match_parent宽度,但它只是包装内容.

我的回收者视图 - :

<?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="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.transenigma.iskconapp.events"
    tools:showIn="@layout/app_bar_events">

    <view
        android:id="@+id/recycler_view"
        class="android.support.v7.widget.RecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="-16dp"
        android:layout_marginRight="-17dp" />

    <!--<ProgressBar-->
        <!--android:id="@+id/progress_bar"-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="wrap_content"-->
        <!--android:layout_centerInParent="true" />-->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

自定义行是 - :

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

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:cardview="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="80dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:orientation="horizontal">

            <FrameLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true">
                <com.transenigma.iskconapp.BlurImageView
                    android:id="@+id/myEventImg"
                    android:layout_width="115dp"
                    android:layout_height="match_parent"
                    android:scaleType="fitXY"
                    android:layout_gravity="center_vertical"
                    android:src="@drawable/mayapur" />
                <TextView
                    android:id="@+id/myAboveDay"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_marginTop="-8dp"
                    android:textSize="50dp"
                    android:text="Hari"
                    android:gravity="center_horizontal"/>

                <TextView …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

1
推荐指数
1
解决办法
4994
查看次数

标签 统计

android ×2

android-recyclerview ×2