I have a RelativeLayout
above my ListView
, and I'm expecting the TextView
on that layout to change based on the content of the first visible item of the ListView
. So I'm using onScrollListener
with my list:
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (adapter != null && adapter.getCount() > 0) {
Transaction data = (Transaction) adapter.getItem(firstVisbileItem);
Date date = data.getTransactionDate();
date.setActualDate(date.getActualDate());
String month = date.getMonthString(context);
String year = date.getYear() + "";
tvLeftValue.setText(month);
tvRightValue.setText(year);
}
}
It's just really weird that when I use this, the list scrolls really slowly, but when I tried using setText("")
for both TextView
, the list scrolls smoothly as normal. This problem occurs when I test on real device (Galaxy S3), not on Genymotion's emulator. Why could such a weird problem happen? Is there any possible solution to this? If any of you have ever encountered this, please help me and thanks in advance.
EDIT: Actually this also happens in Genymotion's emulator, it's just faster than in real devices so I thought it didn't happen.