public class SAdapter extends RecyclerView.Adapter <SAdapter.SHolder>{
TextView textViewProfileNameFeed,textViewTimeFeed, textViewDZCount, textViewFB, textViewTW, textViewS, textViewFeedLocation, buttonPlayVideo;
private MainActivity mainActivity;
ImageView imageViewProfilePicFeed, imageViewBodyFeed;
RelativeLayout relativeLayoutroot;
private RecyclerItemClickListener clickListener;
Context mContext;
private List<SModel> sList = Collections.emptyList();
MediaPlayer mediaPlayer = null;
boolean isPlaying = false;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy");
private static LayoutInflater inflater = null;
public SAdapter(MainActivity mainActivity, List<SModel> sList) {
this.mainActivity = mainActivity;
this.sList = rsList;
Log.d(">>>>>>>>>>>>>>","sList>>>>"+sList);
inflater = (LayoutInflater) mainActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public SHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = inflater.inflate(R.layout.card,parent,false);
View itemView = LayoutInflater.from(mainActivity).inflate(R.layout.card, null, false);
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
itemView.setLayoutParams(lp);
initFont(itemView);
initFont(itemView);
return new SHolder(itemView);
}
答案 0 :(得分:0)
使用
@Override
public SHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card, parent, false);
return itemView;
}
@Override
public void onBindViewHolder(SHolder holder, int position) {
// you probably don't need to set the layout params here...
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
holder.itemView.setLayoutParams(lp);
initFont(holder.itemView);
}