Hi, My ListView (two TextView, one Icon) have more than 4000 rows and It sroll very slowly. The problem is "For{} statement" with "Cursor" make my program worse. I want to get the "First Character"(from one of two TextView) to display when User Scroll. So, any solutions to archive this and make my program better. My function like this:
public void onScroll(AbsListView view, int firstVisibleItem, int VisibleItemCount, int totalItemCount){
//int lastItem = firstVisibleItem + VisibleItemCount - 1;
Cursor cursor = mDbHelper.loadTitleRaw();
startManagingCursor(cursor);
ArrayList<String> myArrayList = new ArrayList<String>();
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()) {
String mTitleRaw = cursor.getString(cursor.getColumnIndex(SBooksDbAdapter.KEY_TITLE_RAW));
myArrayList.add(mTitleRaw);
}
String[] mString = myArrayList.toArray(new String[myArrayList.size()]);
if(mReady){
char firstLetter = mString[firstVisibleItem].charAt(0);
if(!mShowing && firstLetter != mPrevLetter){
mShowing = true;
mDialogText.setVisibility(View.VISIBLE);
}
mDialogText.setText(((Character)firstLetter).toString());
mHandler.removeCallbacks(mRemoveWindow);
mHandler.postDelayed(mRemoveWindow, 3000);
mPrevLetter = firstLetter;
}
}