0

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?

4

1 回答 1

4

尝试这个:

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);
}        
于 2013-08-06T10:05:07.180 回答