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

Unable to start activity ComponentInfo{br.liveo.ndrawer/br.liveo.ndrawer.MainActivity}: java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called. #57

Closed
qferiz opened this issue Jun 2, 2015 · 15 comments

Comments

@qferiz
Copy link

qferiz commented Jun 2, 2015

I run this sample demo project on my devices OS Android Jelly Bean 4.2.2, Forced Closed appear.
I use new version on this Library.
Requires 14+ API and android support v7 22.2.0 (AppCompatActivity + Toolbar)

What wrong ?

And detail LogCat :

06-02 12:13:56.050 21603-21603/br.liveo.ndrawer E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.liveo.ndrawer/br.liveo.ndrawer.MainActivity}: java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2396)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2448)
at android.app.ActivityThread.access$600(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5469)
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:857)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
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:261)
at android.widget.ListView.addHeaderView(ListView.java:290)
at br.liveo.navigationliveo.NavigationLiveo.addHeaderView(NavigationLiveo.java:327)
at br.liveo.navigationliveo.NavigationLiveo.mountListNavigation(NavigationLiveo.java:250)
at br.liveo.navigationliveo.NavigationLiveo.onCreate(NavigationLiveo.java:136)
at android.app.Activity.performCreate(Activity.java:5226)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1151)
at com.lbe.security.service.core.client.b.x.callActivityOnCreate(Unknown Source)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2448)
            at android.app.ActivityThread.access$600(ActivityThread.java:173)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5469)
            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:857)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
            at dalvik.system.NativeStart.main(Native Method)

@qferiz
Copy link
Author

qferiz commented Jun 2, 2015

Strangely, when I run a demo sample of this project, on a different mobile phone with the Android OS 4.4.4 Kitkat running well.

But on LogCat info :

06-02 13:37:54.253 16908-16908/br.liveo.ndrawer I/AppCompatViewInflater﹕ app:theme is now deprecated. Please move to using android:theme instead.

@AlaaMHossam
Copy link

I can confirm that this issue happens on API 17 (android 4.2) and API 15 (android 4.0.3/4.0.4).

A fix is much appreciated.

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

Can you explain where things are happening?

thank you

2015-06-03 7:53 GMT-03:00 Alaa notifications@github.com:

I can confirm that this issue happens on API 17 (android 4.2) and API 15
(android 4.0.3/4.0.4).

A fix is much appreciated.


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@AlaaMHossam
Copy link

I don't understand your question,but this issue happens in the MainActivity class.

@AlaaMHossam
Copy link

here's the output of the logcat:

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.example/com.example.example.MainActivity.MainActivity}: java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
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:257)
at android.widget.ListView.addHeaderView(ListView.java:286)
at br.liveo.navigationliveo.NavigationActionBarLiveo.addHeaderView(NavigationActionBarLiveo.java:246)
at br.liveo.navigationliveo.NavigationActionBarLiveo.mountListNavigation(NavigationActionBarLiveo.java:241)
at br.liveo.navigationliveo.NavigationActionBarLiveo.onCreate(NavigationActionBarLiveo.java:143)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5039)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

What version of the library you are using?

You are using a header customized it?

I need more detail than you are implementing in your MainActivity so I can
identify the problem.

Thank you.

2015-06-03 8:01 GMT-03:00 Alaa notifications@github.com:

here's the output of the logcat:

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.example/com.example.example.MainActivity.MainActivity}:
java.lang.IllegalStateException: Cannot add header view to list --
setAdapter has already been called.
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
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:257)
at android.widget.ListView.addHeaderView(ListView.java:286)
at
br.liveo.navigationliveo.NavigationActionBarLiveo.addHeaderView(NavigationActionBarLiveo.java:246)
at
br.liveo.navigationliveo.NavigationActionBarLiveo.mountListNavigation(NavigationActionBarLiveo.java:241)
at
br.liveo.navigationliveo.NavigationActionBarLiveo.onCreate(NavigationActionBarLiveo.java:143)
at android.app.Activity.performCreate(Activity.java:5104)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at
android.app.ActivityThread.access$600(ActivityThread.java:141)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@AlaaMHossam
Copy link

I am using:

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:support-v13:22.2.0'
compile 'br.com.liveo:navigationdrawer-material:2.3.1'

Let me double check on the header thing,I have not customized it tho.

@AlaaMHossam
Copy link

@OverRide
public void onInt(Bundle bundle) {
// User Information
this.userName.setText("Rudson Lima");
this.userEmail.setText("rudsonlive@gmail.com");
this.userPhoto.setImageResource(R.drawable.ic_rudsonlive);
this.userBackground.setImageResource(R.drawable.ic_user_background_first);

    mListNameItem = new ArrayList<>();

    mListNameItem.add("Home");
    mListNameItem.add("Explore");
    mListNameItem.add("Favourites");

    // Creating items navigation
    mHelpLiveo = new HelpLiveo();
    mHelpLiveo.add("Home", R.drawable.ic_home);
    mHelpLiveo.add("Explore", R.drawable.ic_explore);
    mHelpLiveo.add("Favourites", R.drawable.ic_favourite);
    mHelpLiveo.addSeparator(); // Item separator
    mHelpLiveo.add("Feedback");
    mHelpLiveo.add("Invite Your Friends");
    mHelpLiveo.add("About Let's Go");

    with(this).startingPosition(0) //Starting position in the list
            .addAllHelpItem(mHelpLiveo.getHelp())
           // .removeHeader()

                    //{optional} - List Customization "If you remove these methods and the list will take his white standard color"
                    //.selectorCheck(R.drawable.selector_check) //Inform the background of the selected item color
                    //.colorItemDefault(R.color.nliveo_blue_colorPrimary) //Inform the standard color name, icon and counter
                    //.colorItemSelected(R.color.nliveo_purple_colorPrimary) //State the name of the color, icon and meter when it is selected
                    //.backgroundList(R.color.nliveo_black_light) //Inform the list of background color
                    //.colorLineSeparator(R.color.nliveo_transparent) //Inform the color of the subheader line

                    //{optional} - SubHeader Customization
            .colorItemSelected(Color.parseColor("#424242"))
                    //.colorNameSubHeader(R.color.nliveo_blue_colorPrimary)
                    //.colorLineSeparator(R.color.nliveo_blue_colorPrimary)
                    //.footerItem(R.string.settings, R.mipmap.ic_launcher)

                    //{optional} - Footer Customization
                    //.footerNameColor(R.color.nliveo_blue_colorPrimary)
                    //.footerIconColor(R.color.nliveo_blue_colorPrimary)
                    //.footerBackground(R.color.nliveo_white)

            .setOnClickUser(onClickPhoto)
            .setOnPrepareOptionsMenu(onPrepare)
            .setOnClickFooter(onClickFooter)
            .build();
}

That's the onInt method.

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

Already managed to identify the error.

Today will launch a new version with this fix.

Thank you for your help.

2015-06-03 8:09 GMT-03:00 Alaa notifications@github.com:

I am using:

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:support-v13:22.2.0'
compile 'br.com.liveo:navigationdrawer-material:2.3.1'

Let me double check on the header thing,I have not customized it tho.


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@AlaaMHossam
Copy link

Thank you very much,Sir.

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

I thank you for your help.

I just made a change to the project and soon will generate a new compile
the library.

Thank you.

2015-06-03 8:14 GMT-03:00 Alaa notifications@github.com:

Thank you very much,Sir.


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

Thank you so much for your help.

If everything is ok, please do not forget to close the issues

New version

compile 'br.com.liveo:navigationdrawer-material:2.3.2'

2015-06-03 8:18 GMT-03:00 Rudson Lima rudsonlive@gmail.com:

I thank you for your help.

I just made a change to the project and soon will generate a new compile
the library.

Thank you.

2015-06-03 8:14 GMT-03:00 Alaa notifications@github.com:

Thank you very much,Sir.


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@AlaaMHossam
Copy link

Tested on android 4.0.4 and works like a charm.

Thank you.

@zirouan
Copy link
Owner

zirouan commented Jun 3, 2015

I did my test on the 4.1.1 version of Android and everything went ok.

2015-06-03 8:54 GMT-03:00 Alaa notifications@github.com:

Tested on android 4.0.4 and works like a charm.

Thank you.


Reply to this email directly or view it on GitHub
#57 (comment)
.

Rudson Lima ( live-O ) Desenvolvedor Android
Contato +55 85 87050560* - Fortaleza-ce
*Google Play *CepLive-O e Navigation Drawer - Live-O
https://play.google.com/store/apps/developer?id=Rudson+Lima
*Social
facebook https://www.facebook.com/rudsonlive | google+
http://google.com/+RudsonLima-O | linkedin
http://br.linkedin.com/in/rudsonlive/

@qferiz
Copy link
Author

qferiz commented Jun 3, 2015

Thanks you, libary new version 2.3.2 works perfect on OS Android Jelly Bean 4.2.2 & Kitkat 4.4.4.

Close issues... 👍

@qferiz qferiz closed this as completed Jun 3, 2015
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

No branches or pull requests

3 participants