号码选择器在Recyclerview中不起作用

时间:2018-12-21 17:05:06

标签: android android-layout

recycler_viewholder.xmlRecyclerView

的观看者
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <NumberPicker
        android:layout_width="match_parent"
        android:layout_height="match_parent"></NumberPicker>

</android.support.constraint.ConstraintLayout>

RecyclerView适配器,用于将viewholder添加到Recyclerview

package dallasco.scorecarts.adapters;

    import android.content.Context;
    import android.content.res.AssetManager;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.support.annotation.NonNull;
    import android.support.v7.widget.RecyclerView;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ImageView;

    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;


    public class SubTBGAdapter extends RecyclerView.Adapter<SubTBGAdapter.TBGViewHolder> {


        private static final String TAG = "Hi";
        private static int viewHolderCount;
        private int mNumberItems;
        private String[] fileNames;
        private Context context;
        private View.OnClickListener listener;
        private int questionNo;
        private String tbgType;

        public SubTBGAdapter() {
            super();
        }

        public SubTBGAdapter(int numOfItems) {
            mNumberItems = numOfItems;
        }

        @Override
        public long getItemId(int position) {
            return super.getItemId(position);
        }

        @Override
        public void onBindViewHolder(@NonNull TBGViewHolder holder, int position) {
            holder.bind(position);
        }

        @Override
        public int getItemCount() {
            return mNumberItems;
        }



        @NonNull
        @Override
        public TBGViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
            Context context = viewGroup.getContext();
            boolean shouldAttachToParentImmediately = false;
            View view = inflater.inflate(R.layout.recycler_viewholder, viewGroup, shouldAttachToParentImmediately);
                Log.e("CreatingViewHolder", viewHolderCount + "");
                TBGViewHolder tbgViewHolder = new TBGViewHolder(view, layoutIdForListItem, viewHolderCount);
                viewHolderCount++;
                return tbgViewHolder;
            }
            public TBGViewHolder(View itemView, int layoutId, int index) {


            void bind(int listIndex) {
    //            Log.e("List Index", Integer.toString(listIndex));
                //textView.setText(questions.get(listIndex).getStatement());]
            }


            @Override
            public void onClick(View v) {

            }




    }

填充了“回收站”视图,但视图支架内部的数字选择器不起作用。

recyclerview工作正常,它填充了viewholders。但是viewholder中的数字选择器不会滚动,而是冻结了。 '

0 个答案:

没有答案