Dan:

I don't know if it's right or best practice, but for this type of complicate
layout, I choose to get away from the XML and build my layouts
programmatically.  I have a similar list, and when I need to show a Category
header, I just call the following function during the build:

    private void appendSubHead(TableLayout table, String value) {
        
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.FILL_PARENT,
        LinearLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(0, 20, 0, 0);
        
        TextView subhead = new TextView(this);
        subhead.setHeight(40);
        subhead.setTextSize(18);
        subhead.setTextColor(Color.BLACK);
        subhead.setSingleLine(true);
        subhead.setTypeface(Typeface.DEFAULT_BOLD);
        subhead.setText(value);
        subhead.setPadding(0, 10, 0, 0);
        
        table.addView(subhead, layoutParams);
        
    }

Thanks,
Nick Owens
VP, ThreeClix
Office: (904) 429-7039
Mobile: (847) 565-9392
After Hours: (904) 540-5830


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dan
Sent: Thursday, February 18, 2010 4:43 PM
To: Android Developers
Subject: [android-developers] Custom ListView

I'm developing an app that requires a custom ListView which I have
created to show a list of movies.  I now would like to add some
category dividers to the listview so that the movies are divided into
groups, such as sorting by genre.  I'm just not sure how to add the
category dividers to my listview? would I need a separate xml layout
for the category row and inject it between the movies in my listview
or is there a standard, simpler way to do it?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to