问题
I create a RecyclerView with CardViews in my app. Now I want to add inside each CardView a new List of custom Views, with a custom layout (see example Image). When the add button is pressed, there should be insert a new row of this layout inside the card.
How do I realize that? In the internet I readed, that a ListView inside the CardView is not possible, because a ListView is scrollable, and there should not be two scrollable Views on the activity (thats what I found..)

the red marked row is the custom row.
for the RecylcerView I used the ViewHolder, CustomAdapter, etc. Do I need this for the rows inside to? or is there a simpler way?
回答1:
What I would do is attached a click handler to the Views
is your ViewHolder
. In this event handler you can delegate to a presenter of some sort that will add/remove/edit the View
in the card holder.
private class MyHolder extends ViewHolder
implements View.OnClickListener {
...
public MyHolder(View itemView, MyPresenter presenter) {
super(itemView);
itemView.setOnClickListener(this);
...
}
@Override
public void onClick(View v) {
presenter.addRow(v);
}
}
来源:https://stackoverflow.com/questions/31203040/create-cardview-with-dynamic-custom-list-inside