Skip to content Skip to sidebar Skip to footer

Different "visibility" Values In Each Row In A Listview

I have developed a very simple app that uses a custom adapter for a ListView. Each row has two TextViews:

Solution 1:

This has a problem for the exact same reason I described in notes on your previous question. The view is being recycled, so the customization performed in the clause if (list_item.hasText2()) { is permanently set on that view; even when recycled to a view for which that clause would not be true.

In this case the following modification would probably fix the issue:

 if (list_item.hasText2()) {
    text2.setText(list_item.getText2());
    text2.setVisibility(View.VISIBLE);
 } else {
    text2.setVisibility(View.GONE);
 }

Post a Comment for "Different "visibility" Values In Each Row In A Listview"