Recyclerview Itemclick Не работает гладко - PullRequest
0 голосов
/ 02 февраля 2020

У меня есть sothree slidinguppanel макет. В одной части есть viewpager, а во второй части recyclerview У меня есть событие щелчка элемента просмотра для просмотра повторного просмотра для второго просмотра. это работает, но не так, как ожидалось. Он работает после каждых 3-4 кликов. Ниже мой xml файл. как решить эту проблему

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoDragView="@+id/dragView"
    sothree:umanoOverlay="true"
    sothree:umanoPanelHeight="350dp"
    sothree:umanoParalaxOffset="100dp"
    sothree:umanoShadowHeight="4dp">

    <!-- MAIN CONTENT -->
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!--show image slider-->
        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            />

        <LinearLayout
            android:id="@+id/SliderDots"
            android:layout_below="@+id/viewPager"
            android:orientation="horizontal"
            android:gravity="center_vertical|center_horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <!--end image slider-->

        <TextView
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:clickable="true"
            android:focusable="false"
            android:text="text1"
            android:visibility="gone"
            android:textColor="@android:color/holo_blue_dark"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:textSize="16sp" />

        <Button
            android:id="@+id/btn_show"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/text"
            android:layout_centerInParent="true"
            android:layout_marginRight="15dp"
            android:layout_marginLeft="15dp"
            android:text="btn1"
            android:visibility="gone" />
    </RelativeLayout>

    <!-- SLIDING LAYOUT -->
    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:clickable="true"
        android:focusable="false"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal">


            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:visibility="gone"
                android:src="@drawable/minus"></ImageView>

            <TextView
                android:id="@+id/name"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:textColor="@android:color/holo_green_dark"
                android:gravity="center_vertical"
                android:paddingLeft="10dp"
                android:text="slide1"
                android:visibility="gone"
                android:textSize="14sp" />

            <Button
                android:id="@+id/btn_hide"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_vertical|right"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text="hide1"
                android:visibility="gone"
                android:textSize="14sp" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/dragView"
            android:clickable="true"
            android:focusable="false"
           >


            <!-- Bids View with appbar layout-->

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                >

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_books_status"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/white">
                </android.support.v7.widget.RecyclerView>

            </LinearLayout>
            <!-- Ends Bids view with appbar layout-->
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerview_books"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:clipToPadding="false"
                android:background="@color/white">
            </android.support.v7.widget.RecyclerView>
        </LinearLayout>

    </LinearLayout>


</com.sothree.slidinguppanel.SlidingUpPanelLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@id/sliding_layout"
    android:layout_alignParentBottom="true"
    android:padding="8dp">

    <TextView
        android:id="@+id/tvNointernet"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textColor="@color/cb_errorRed"
        android:textSize="18dp"
        android:padding="5dp"
        android:background="@color/yellows"
        android:text="No Internet"></TextView>
</LinearLayout>

</RelativeLayout>

И это мое onBindViewholder событие кликающего элемента

  @Override
    public void onBindViewHolder(BookItemView holder, final int position) {

        holder.bind(mBookList.get(position),mkeys.get(position));

        /*Making Layout Clickable to submit bid added by me*/

        final String bidPosition=mkeys.get(position).toString();

        holder.itemView.setOnClickListener(mClick);
    }

    View.OnClickListener mClick=new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(mContext, "I am clicked", Toast.LENGTH_SHORT).show();
        }
    };

    @Override
    public int getItemCount() {
        return mBookList.size();
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...