Skip to content

Feature/fix custom header crash - #1

Open
hffmnn wants to merge 4 commits into
smbarne:masterfrom
hffmnn:feature/fix_custom_header_crash
Open

Feature/fix custom header crash#1
hffmnn wants to merge 4 commits into
smbarne:masterfrom
hffmnn:feature/fix_custom_header_crash

Conversation

@hffmnn

Copy link
Copy Markdown

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.

hffmnn added 4 commits April 2, 2014 14:51
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)
@smbarnesmbarne self-assigned this Jul 17, 2014
@zhaoyou

Copy link
Copy Markdown

+1

Sign up for freeto 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

@hffmnn@zhaoyou@smbarne