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

Help: Error inflating class fragment #535

Closed
DuarteBarbosaPT opened this issue Mar 5, 2016 · 0 comments
Closed

Help: Error inflating class fragment #535

DuarteBarbosaPT opened this issue Mar 5, 2016 · 0 comments

Comments

@DuarteBarbosaPT
Copy link

Hi
I am pretty new to androi studio and i got this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.quarkprojects.socialnetworkcards/com.quarkprojects.socialnetworkcards.MainActivity}: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class fragment
                                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                          at android.os.Looper.loop(Looper.java:148)

Total error at:
http://pastebin.com/va7DG1tf

This is my fragment code:
http://pastebin.com/pgRi9rLq

This is my main_activity.xml:
http://pastebin.com/nm3d9Mn2

This is my fragment_cards_activity.xml
http://pastebin.com/bP9wi7gF

Thanks

// UPDATE:
I have changed alot of the code to something near what you have here:
https://github.com/gabrielemariotti/cardslib/blob/d80384806cdffd2acc559bf1167251dcc797fa97/demo/stock/src/main/java/it/gmariotti/cardslib/demo/fragment/v1/CardFragment.java

And it crashed again.
Unable to start activity ComponentInfo{com.quarkprojects.socialnetworkcards/com.quarkprojects.socialnetworkcards.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void it.gmariotti.cardslib.library.view.CardView.setCard(it.gmariotti.cardslib.library.internal.Card)' on a null object reference

it allways crashed after this:
cardView.setCard(card);
And on debugging, this comes always null:

CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_card_id);

Update 2:
Fixed it by creating a onAcitivityCreated

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);


        initCard();
    }
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

1 participant