2

I've got a layout that I'm trying to set up that is comprised of three different layouts merged into one. I have two RelativeLayouts as the first two items and a list adapter as the third. The reason for using MergeAdapter is because I want the entire page to scroll, but I want the second total item in the entire layout (the second RelativeLayout) to stick to the top. So I'm trying to use the StickyListHeaders Library to accomplish it.

It doesn't seem like it's too widely used yet, even though the idea of it is awesome. Anyways, There are two methods I have to override in my list adapter, which in this case is a MergeAdapter. I keep getting a NullPointerException, but it doesn't tell me where in my code it's happening. So if anyone has experience using the library, and more specifically using the library with MergeAdapter, could you tell me what I'm doing wrong? Here's the code for my MergeAdapter.

private class ProfileMergeAdapter extends MergeAdapter implements StickyListHeadersAdapter{

    @Override
    public View getHeaderView(int position, View convertView, ViewGroup parent) {

        LayoutInflater nameInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = (RelativeLayout) nameInflater.inflate(R.layout.name_line, null);
        profilePhotoBottom = (ImageView) convertView.findViewById(R.id.profile_pic_bottom);
        TextView userName = (TextView) convertView.findViewById(R.id.userName);
        userName.setText(Utility.userName);
        return convertView;
    }

    @Override
    public long getHeaderId(int position) {
        return 1;
    }

}

And here's the logcat:

01-13 20:39:21.237: W/dalvikvm(4917): threadid=1: thread exiting with uncaught exception (group=0x40de5930)
01-13 20:39:21.245: E/AndroidRuntime(4917): FATAL EXCEPTION: main
01-13 20:39:21.245: E/AndroidRuntime(4917): java.lang.NullPointerException
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:523)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.View.measure(View.java:15513)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.measureHeader(StickyListHeadersListView.java:242)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.scrollChanged(StickyListHeadersListView.java:284)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.onScroll(StickyListHeadersListView.java:269)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1340)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.ListView.layoutChildren(ListView.java:1753)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.AbsListView.onLayout(AbsListView.java:1994)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.View.layout(View.java:14003)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.View.layout(View.java:14003)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.View.layout(View.java:14003)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.View.layout(View.java:14003)
01-13 20:39:21.245: E/AndroidRuntime(4917):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Wenger
  • 989
  • 2
  • 12
  • 35
  • Well, I'd first remove the `MergeAdapter`, and see if you can get the other library working with just a regular adapter. – CommonsWare Jan 14 '13 at 11:45

1 Answers1

0

Thanks for the response Mark. I figured it out, kinda. I guess something was screwy with my layout_width and layout_height in my xml for one of the list items and changing them around didn't work. So I changed the the item height and width using LayoutParams in the code.

Wenger
  • 989
  • 2
  • 12
  • 35