Android – onviewcreated and compatible Libraries

In the Android application, I implemented a fragment that will override onviewcreated to set up some onclicklisteners once the view exists

Everything is fine when I implement it. However, as long as I add the compatibility library V4 R3, it seems that I won't call this method at all

Now I migrate my settings to onresume, but this is really not ideal. So this is my problem:

>Is this an error in the compatibility library? > Is there a better solution?

After some digging and trying different things, I got this stack trace, which made me believe that it was indeed an error in the compatibility library

10-07 14:25:11.130: ERROR/AndroidRuntime(2964): FATAL EXCEPTION: main
        java.lang.NoSuchMethodError: android.support.v4.app.Fragment.onViewCreated
        at roboguice.fragment.RoboFragment.onViewCreated(RoboFragment.java:18)

But what's more strange is that when you look at the compatibility library source, the method actually exists, but it is empty

resolvent:

After many rounds of debugging, I found the problem. It has been proved that I used the old version of the compatibility Library in my project. Now I have updated my project and it works normally. As a reference, the required change is the compatibility library dependency in the Maven POM file

        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v4</artifactId>
            <version>r3</version>
        </dependency>

Use Maven Android SDK deployer to deploy the library to your Maven warehouse. I also have updated the roboguice Wiki and linked gist on my GitHub account

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>