Git Product home page Git Product logo

android-issues's Introduction

记录Android 开发中遇到的问题

1. 使用android.support.design.widget.TabLayout时,crash掉?
    Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
    解决办法:use a Theme.AppCompat theme
2. Scrollview嵌套ViewPager时,ViewPager不显示或者不完全显示?
    重写ViewPager的onMeasure方法即可.如下:
    int mHeight = 0;
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            for (int i = 0; i < getChildCount(); i++) {
                    View child = getChildAt(i);
                    child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                    int h = child.getMeasuredHeight();
                    if (h > mHeight){
                            mHeight = h;
                    }
            }
            heightMeasureSpec = MeasureSpec.makeMeasureSpec(mHeight, MeasureSpec.EXACTLY);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
3.OuterFragment嵌套InnerFragment时,ViewPager 加载 InnerFragment 出现空白页的情况?
    The definition of getChildFragmentManager() is:
            Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
    Meanwhile the definition of getFragmentManager() (or in this case getSupportFragmentManager()) is:
            Return the FragmentManager for interacting with fragments associated with this fragment's activity.

    Basically, the difference is that Fragment's now have their own internal FragmentManager that can handle Fragments.
    The child FragmentManager is the one that handles Fragments contained within only the Fragment that it was added to. 
    The other FragmentManager is contained within the entire Activity.

    In this case, what I'm guessing is you've added the Fragments to the Activity's FragmentManager. 
    You get the child FragmentManager which doesn't contain what you are looking for.
    Thus you get the exception because it can't find the Fragment with the given ID 
    because it's in a different FragmentManager.

android-issues's People

Contributors

gongwen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.