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

Feature/fix custom header crash #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Feature/fix custom header crash #1

wants to merge 4 commits into from

Conversation

hffmnn
Copy link

@hffmnn hffmnn commented Apr 2, 2014

When clicking a station on the second list view, e.g. Bowdoin, the app crashes, as described in commit a497a45

This PR tries to fix that by changing the timing of setting the adapter vs. setting the header view, but I am not sure, if I do it at the correct position in the fragment lifecycle.

04-02 15:04:28.194  14490-14490/com.example.androidforios.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidforios.app/com.example.androidforios.app.activities.TripDetailActivity}: java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
            at android.widget.ListView.addHeaderView(ListView.java:258)
            at android.widget.ListView.addHeaderView(ListView.java:287)
            at com.example.androidforios.app.fragments.TripDetailFragment.onViewCreated(TripDetailFragment.java:73)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:941)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
            at android.app.Activity.performStart(Activity.java:5143)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
@smbarne smbarne self-assigned this Jul 17, 2014
@zhaoyou
Copy link

zhaoyou commented Sep 20, 2016

+1

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

Successfully merging this pull request may close these issues.

3 participants