recycler_viewholder.xml
是RecyclerView
<?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
中的数字选择器不会滚动,而是冻结了。
'