Reputation: 5550
Please take a look at the code snippet below:
imageContainer.addView(imageA);
imageContainer.addView(imageB);
textContainer.addView(text);
row.addView(textContainer);
row.addView(imageContainer);
row.setId(i);
row.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Try to remove this row's imageB when onClick
}
})
From the above code, how should the objective can be achieved if I would like to remove only imageB from that particular row when onClick?
Upvotes: 0
Views: 191
Reputation: 2246
Try this:
public void onClick(View v){
TableRow row= (TableRow) findViewById(v.getId());
imageContainer=(<imageContainertype>) row.getChildAt(1);
ImageView imageB =(ImageView) imageContainer.getChildAt(1);
imageContainer.removeView(imageB);
}
Upvotes: 4