Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in RelativeLayout.onMeasure() #69

Closed
androidmoney opened this issue Feb 3, 2013 · 9 comments
Closed

Crash in RelativeLayout.onMeasure() #69

androidmoney opened this issue Feb 3, 2013 · 9 comments
Labels

Comments

@androidmoney
Copy link
Contributor

I had the following layout for my header:

<RelativeLayout android:id="@+id/date_header_group"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

    <TextView android:id="@+id/date_header"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_alignParentTop="true"
              android:paddingLeft="5dp"
              android:paddingRight="5dp"/>                      

    <View android:layout_width="0px"
          android:layout_height="2dp"
          android:layout_centerVertical="true"
          android:layout_alignParentLeft="true"
          android:layout_toLeftOf="@+id/date_header"
          android:background="@drawable/divider_horizontal_dark_opaque"/>

    <View android:layout_width="0px"
          android:layout_height="2dp"
          android:layout_centerVertical="true"
          android:layout_alignParentRight="true"
          android:layout_toRightOf="@+id/date_header"
          android:background="@drawable/divider_horizontal_dark_opaque"/>
</RelativeLayout>

<com.actionbarsherlock.internal.widget.CapitalizingTextView
          android:id="@android:id/text1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:paddingLeft="10dp"
          style="?android:attr/listSeparatorTextViewStyle"/>        

When I used this layout as a header, I got a crash:

java.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:523)
at android.view.View.measure(View.java:15513)
at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.measureHeader(StickyListHeadersListView.java:253)
at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.scrollChanged(StickyListHeadersListView.java:311)
at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.onScroll(StickyListHeadersListView.java:280)
at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1340)
at android.widget.ListView.layoutChildren(ListView.java:1753)
at android.widget.AbsListView.onLayout(AbsListView.java:1994)
at com.emilsjolander.components.stickylistheaders.StickyListHeadersListView.onLayout(StickyListHeadersListView.java:112)

I fixed it by changing the RelativeLayout to a FrameLayout, which it should have been anyhow, but the point remains that it should not crash.

@androidmoney
Copy link
Contributor Author

No idea why this got cut off:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="wrap_content">

<RelativeLayout android:id="@+id/date_header_group"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

    <TextView android:id="@+id/date_header"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_alignParentTop="true"
              android:paddingLeft="5dp"
              android:paddingRight="5dp"/>                      

    <View android:layout_width="0px"
          android:layout_height="2dp"
          android:layout_centerVertical="true"
          android:layout_alignParentLeft="true"
          android:layout_toLeftOf="@+id/date_header"
          android:background="@drawable/divider_horizontal_dark_opaque"/>

    <View android:layout_width="0px"
          android:layout_height="2dp"
          android:layout_centerVertical="true"
          android:layout_alignParentRight="true"
          android:layout_toRightOf="@+id/date_header"
          android:background="@drawable/divider_horizontal_dark_opaque"/>
</RelativeLayout>

<com.actionbarsherlock.internal.widget.CapitalizingTextView
          android:id="@android:id/text1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:paddingLeft="10dp"
          style="?android:attr/listSeparatorTextViewStyle"/>        
</RelativeLayout>

@emilsjolander
Copy link
Owner

Nice catch, very weird though. This will hopefully have fixed itself in the
rewrite I am working on.

Emil Sjölander
emilsjolander.se
On Feb 3, 2013 10:47 AM, "Tom" notifications@github.com wrote:

No idea why this got cut off:

<TextView android:id="@+id/date_header"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_alignParentTop="true"
          android:paddingLeft="5dp"
          android:paddingRight="5dp"/>

<View android:layout_width="0px"
      android:layout_height="2dp"
      android:layout_centerVertical="true"
      android:layout_alignParentLeft="true"
      android:layout_toLeftOf="@+id/date_header"
      android:background="@drawable/divider_horizontal_dark_opaque"/>

<View android:layout_width="0px"
      android:layout_height="2dp"
      android:layout_centerVertical="true"
      android:layout_alignParentRight="true"
      android:layout_toRightOf="@+id/date_header"
      android:background="@drawable/divider_horizontal_dark_opaque"/>

<com.actionbarsherlock.internal.widget.CapitalizingTextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
style="?android:attr/listSeparatorTextViewStyle"/>


Reply to this email directly or view it on GitHubhttps://github.com//issues/69#issuecomment-13044673.

@emilsjolander
Copy link
Owner

could you please test this with the current version? probably not an issue anymore :)

@androidmoney
Copy link
Contributor Author

I will try in a few days (I am on vacation now), but if there really is an issue with setting an adapter without data, please address that as I do that quite a bit in my app.

@emilsjolander
Copy link
Owner

of course, i also do this often

@emilsjolander
Copy link
Owner

setting the adapter with no info is now working. Get back to me when you have had a chance to try this issue with the newest build :)

@androidmoney
Copy link
Contributor Author

This is fixed.

@emilsjolander
Copy link
Owner

thx!

@Zordid
Copy link

Zordid commented Jun 29, 2013

I got the same issue again. Using a RelativeLayout as a header seems to be problematic! Don't know why. My RelativeLayout is very simple - contains only 2 TextViews one left aligned, one right aligned.
I got exactly the same stack trace as described here with the latest version of your library...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants