Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:46:50+00:00 2026-06-10T20:46:50+00:00

I’ve got a ListFragment, which uses a cursorLoader and custom adapter to populate the

  • 0

I’ve got a ListFragment, which uses a cursorLoader and custom adapter to populate the views in a list. The list contains the albums by a particular band, and ideally the top of the list (header) would display the band name and “all songs” or something similar.

The problem is that when I use addHeaderView() to add the header to the list, the adapter treats the header as just another item in the list, and tries to fill it with the information that would ideally only fill the rows below the header.

I’ve tried using the following inside the bindView in the adapter:

if (cursor.getPosition() == 0)) {
return; }
else {bind the rest of the views}

But it seems to act strangely – sometimes not binding either of the first two rows..

Below is some code snippets:

Inside the listFragment:

    albumsAdapter = new AlbumAdapter(getActivity(), null, 0);

    setListAdapter(null);

    if (showHeader) {
        ViewGroup parent = (ViewGroup) getActivity().findViewById(
                R.id.relativeLayoutTest);
        View view = (View) getActivity().getLayoutInflater().inflate(
                R.layout.albumitem, parent, true);
        TextView textView = (TextView) getActivity().findViewById(
                R.id.artistTitle);
        textView.setText("Artist");

        getListView().addHeaderView(view);

    }

    setListAdapter(albumsAdapter);

And the custom adapter:

package another.music.player;

/*  imports etc
*/

class AlbumAdapter extends CursorAdapter {

public AlbumAdapter(Context context, Cursor c, int flags) {
    super(context, c, flags);
}

private static Uri currentSongUri;

@Override
public void bindView(View view, Context context, Cursor cursor) {

    ImageView albumArt = (ImageView) view.getTag(R.id.albumArt);
    TextView text1 = (TextView) view.getTag(R.id.artistTitle);
    TextView text2 = (TextView) view.getTag(R.id.albumTitle);

    albumArt.setImageBitmap(null);

    text1.setText(cursor.getString(cursor
            .getColumnIndex(AudioColumns.ARTIST)));
    text2.setText(cursor.getString(cursor
            .getColumnIndex(AudioColumns.ALBUM)));

    String currentAlbumId = cursor.getString(cursor
            .getColumnIndex(BaseColumns._ID));

    Integer currentAlbumIdLong = Integer.parseInt(currentAlbumId);
    Uri artworkUri = Uri.parse("content://media/external/audio/albumart");
    currentSongUri = ContentUris.withAppendedId(artworkUri,
            currentAlbumIdLong);

    ImageLoader imageLoader = new ImageLoader();
    imageLoader.load(currentSongUri, albumArt, context);

}

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

    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(R.layout.albumitem, null);
    view.setTag(R.id.albumArt, view.findViewById(R.id.albumArt));
    view.setTag(R.id.artistTitle, view.findViewById(R.id.artistTitle));
    view.setTag(R.id.albumTitle, view.findViewById(R.id.albumTitle));

    return view;
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:46:52+00:00Added an answer on June 10, 2026 at 8:46 pm

    As I see it, your headerView uses the same layout file as the adapter. Change it’s name and the View ids inside. This will solve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.