Coder Social home page Coder Social logo

添加依赖后会崩溃 about pandora HOT 5 CLOSED

whataa avatar whataa commented on May 12, 2024
添加依赖后会崩溃

from pandora.

Comments (5)

whataa avatar whataa commented on May 12, 2024

你好,贴出的日志里没有Pandora相关的错误代码?

from pandora.

xiecai1234 avatar xiecai1234 commented on May 12, 2024

嗯。只在build.gradle里加了依赖,代码里没有调用。Activity里套一个fragment,fragment的onCreateView里执行如下代码。用最新的有问题,还原到之前的v1.2.2就没问题了。如下:
mViewPager.setAdapter(myHomeViewPagerAdapter);
mTablayout.setTabMode(TabLayout.MODE_FIXED);
mTablayout.setVisibility(View.VISIBLE);
mTablayout.post(new Runnable() {
@OverRide
public void run() {
setIndicator(mTablayout, 40, 40);
}
});

public void setIndicator(TabLayout tabs, int leftDip, int rightDip) {
Class<?> tabLayout = tabs.getClass();
Field tabStrip = null;
try {
tabStrip = tabLayout.getDeclaredField("mTabStrip");
} catch (NoSuchFieldException e) {
e.printStackTrace();
}

    tabStrip.setAccessible(true);

from pandora.

whataa avatar whataa commented on May 12, 2024

v1.2.2使用的 design 库的版本是 26.1.0,我看了下其中的Tablayout类里面有你反射需要的mTabStrip 字段,后面经过多次迭代,Pandora最新的版本引用的design 的版本已经提升到 28.0.0 了,对应的类中已经不包含该字段,所以你反射得到的对象是null。

你可以修改你使用TabLayout的方案 或者 通过transitive使用你自己的design版本:

    implementation ("com.github.whataa:pandora:v2.0.3") {
        exclude group: 'com.android.support', module: 'design'
    }
    implementation "com.android.support:design:26.1.0"

from pandora.

xiecai1234 avatar xiecai1234 commented on May 12, 2024

给力!

from pandora.

whataa avatar whataa commented on May 12, 2024

#56

from pandora.

Related Issues (20)

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.