Inflate in Recycler Adapter
make a xml for linear layout child that you want to inflate in linear layout
Simple function in adapter
private void inflateProgressBar(LinearLayout linearLayout) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View viewItem = layoutInflater.inflate(R.layout.item_linear_layout_friends_stories, null);
ProgressBar progressBar = viewItem.findViewById(R.id.progressBar1);
linearLayout.addView(viewItem);
}
call from onBindViewHolder
inflateProgressBar(myViewHolder.progressBarLinearLayout);
public class MyViewHolder extends ViewHolder {
LinearLayout progressBarLinearLayout;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
progressBarLinearLayout = itemView.findViewById(R.id.progressBarLinearLayout);
}
}