I am showing 17 CardViews.
I use RecyclerView to achieve the same.
Each CardView shows general data (format).
Depending on the data received from the JSON file, some additional lines may appear on the map.
. The following figure shows 2 CardViews (in focus) displaying additional data, the rest displaying general data.
It is displayed correctly. But then, when I scroll down to the View view, the last CardView does not have to display any row, but it copies one of one of the two that we saw in the link above and displays. [Can only send 2 links at a time]
, :

?
. . , , . :
@Override
public void onBindViewHolder(DataObjectHolder holder, final int position) {
HashMap<Integer, ShoppingCartSummaryObject> dataItem = new HashMap<Integer, ShoppingCartSummaryObject>();
dataItem = mDataset.get(position);
TextView textViewComment = holder.textViewComment;
ShoppingCartSummaryObject obj = new ShoppingCartSummaryObject();
obj = (ShoppingCartSummaryObject) dataItem.get(position);
holder.textViewPackageType.setText(obj.getPackageType());
holder.textViewPackageCode.setText(obj.getPackageCode());
holder.textViewPackageDesc.setText(obj.getPackageDesc());
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
try {
for (int i = 0; i < obj.getArrayListPart().size(); i++) {
View view2 = LayoutInflater.from(mContext).inflate(R.layout.detailrow, null);
holder.advPartDesc = (TextView) view2.findViewById(R.id.advPartDesc);
holder.advPartnum = (TextView) view2.findViewById(R.id.advPartNum);
cv = holder.cv;
advisoryLayout = holder.advisoryLayout;
empty = holder.empty;
layoutPackageSummary = holder.layoutPackageSummary;
holder.detailRow = (RelativeLayout) view2.findViewById(R.id.detailRow);
rallyLayout = new RelativeLayout(mContext);
rallyLayout.addView(holder.detailRow);
cnt+=1;
rallyLayout.setId(cnt);
holder.layoutpartList.addView(rallyLayout);
if (i == 0) {
params.addRule(RelativeLayout.BELOW, empty.getId() );
holder.advPartnum.setText(obj.getArrayListPart().get(i).partCode);
holder.advPartDesc.setText(obj.getArrayListPart().get(i).partDesc);
rallyLayout.setLayoutParams(params);
} else {
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, cnt - 1);
holder.advPartnum.setText(obj.getArrayListPart().get(i).partCode);
holder.advPartDesc.setText(obj.getArrayListPart().get(i).partDesc);
rallyLayout.setLayoutParams(params);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
:
if(obj.getArrayListPart().size()>0) {
if (i == 0) {
params.addRule(RelativeLayout.BELOW, empty.getId());
holder.advPartnum.setText(obj.getArrayListPart().get(i).partCode);
holder.advPartDesc.setText(obj.getArrayListPart().get(i).partDesc);
rallyLayout.setLayoutParams(params);
} else {
params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, cnt - 1);
holder.advPartnum.setText(obj.getArrayListPart().get(i).partCode);
holder.advPartDesc.setText(obj.getArrayListPart().get(i).partDesc);
rallyLayout.setLayoutParams(params);
}
}
else
{
holder.advPartnum.setText("abc");
holder.advPartDesc.setText("abc");
}
}
} catch (Exception e) {
e.printStackTrace();
}
:
@Override
public long getItemId(int position) {
return super.getItemId(position);
}
.
JSON, , / (), , , /. :
mAdapter.setHasStableIds(true);
, .
. , .