Tôi có bộ điều hợp máy nhắn tin giả sử để thổi phồng một chế độ xem phức tạp đại diện cho một lịch.Làm cách nào để triển khai cơ chế tái chế chế độ xem cho PagerAdapter?
Mất khoảng 350 mili giây để thổi phồng mỗi năm của lịch.
Để cải thiện hiệu suất, tôi muốn triển khai cùng một cơ chế tồn tại trong bộ điều hợp mảng ListView
của chế độ xem tái chế (convertView
tham số trong getView()
).
Đây là số getView()
hiện tại của tôi từ bộ điều hợp.
@Override
protected View getView(VerticalViewPager pager, final DateTileGrid currentDataItem, int position)
{
mInflater = LayoutInflater.from(pager.getContext());
// This is were i would like to understand weather is should use a recycled view or create a new one.
View datesGridView = mInflater.inflate(R.layout.fragment_dates_grid_page, pager, false);
DateTileGridView datesGrid = (DateTileGridView) datesGridView.findViewById(R.id.datesGridMainGrid);
TextView yearTitle = (TextView) datesGridView.findViewById(R.id.datesGridYearTextView);
yearTitle.setText(currentDataItem.getCurrentYear() + "");
DateTileView[] tiles = datesGrid.getTiles();
for (int i = 0; i < 12; i++)
{
String pictureCount = currentDataItem.getTile(i).getPictureCount().toString();
tiles[i].setCenterLabel(pictureCount);
final int finalI = i;
tiles[i].setOnCheckedChangeListener(new DateTileView.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(DateTileView tileChecked, boolean isChecked)
{
DateTile tile = currentDataItem.getTile(finalI);
tile.isSelected(isChecked);
}
});
}
return datesGridView;
}
Bất kỳ con trỏ hoặc hướng nào để thực hiện hành vi như vậy? Cụ thể như thế nào tôi có thể biết trong bộ điều hợp mà một trong số DateTileGridViews
đang được vuốt màn hình để tôi có thể lưu nó vào bộ nhớ để tái sử dụng nó vào lần sau.
Cảm ơn bạn rất nhiều! – penguin86