3

I have listview with custom cursoradapter. It contains few hundred of items. Scrolling down is smooth and fast but scrolling back - up is freezing all the time. I don't load image or some operation on UI thread. Only get few values from cursor and set it into textviews

private class EpisodesAdapter extends CursorAdapter {
        LayoutInflater inflater;
        public EpisodesAdapter(Context context) {
            super(context, null, false);
            inflater = (LayoutInflater)     context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {

            View view = inflater.inflate(R.layout.list_item_episode, parent,  false);

            view.setBackgroundResource(R.drawable.abs__list_selector_holo_light);
            return view;
        }

        @Override
        public void bindView(View view, final Context context, final Cursor cursor) {
            final String title = cursor.getString(EpisodesQuery.EPISODE_TITLE);
            final String episodeId = cursor.getString(EpisodesQuery.EPISODE_ID);
            final String time = cursor.getString(EpisodesQuery.EPISODE_PUBLISHED_AT);
            final String episodeUrl = cursor.getString(EpisodesQuery.EPISODE_URL);
            final int stateId = cursor.getInt(EpisodesQuery.EPISODE_STATE_ID);

                        ((TextView) view.findViewById(R.id.title)).setText(title);
                        ...... 
                }
}

Some thoughts what can be causing this problem?

Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63
  • If the app completely freezes, there might be a logcat message explaining the problem. Are you seeing anything there? – Bryan Herbst Oct 29 '12 at 17:10
  • Have you tried general performance improvements like view holders or async task loaders? – jsmith Oct 29 '12 at 17:11
  • I think you need to close a cursor after its use. Check the logcat it may show some info about why its freezing – G_S Oct 29 '12 at 17:12
  • 1. Only message in logcat is Cursor window: Window is full but I see it also when scrolling down and it works smoothly 2. Yes I tried. I load only data from cursor. Viewholder is not used in cursoradapter because it has own getview implementation which handles it. Newview is called only few time, and bindview is called for every row. 3. Where to close cursor? Cursor adapter handles it and I can't close it in bindview I don't know what can be problem because scrolling through whole list down is good, but once I reach the end and try to scroll up it's freezing. It's very strange. – Martin Vandzura Oct 29 '12 at 17:22

2 Answers2

1

I think I got it. One column in cursor contains some blob data. When I removed this column from query selection, it scroll up smoothly. Thanks for all answers.

Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63
0

ListView empty if SimpleCursorAdapter closed(). This link might answer of where to close cursor. If it scrolls down smoothly i see no reason for freezing when scrolling up. I am curious about the problem your facing.

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • cursoradapter don't need viewholder. newview and bindview already handle it. As I told. Scrolling down is smooth, only when I trie scroll up it starts freezing. – Martin Vandzura Oct 29 '12 at 17:27