Following is the code from RecyclerView
onBindViewHolder
method.
Inside the recycler view I am creating a button Dynamically as shown below.
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
.
.
.
Button button1 = new Button(context);
holder.phoneContainer.addView(button1);
}
When I Scroll the App in Device (when Running in real Device), The Button is created again.
It is supposed to attach 1 button in every cardview
but when ever I scroll the button is created.
Any way to remove the existing views
inside holder.phoneContainer
or
creating only once?