0

my app uses DirectionalViewPager library which has own support-library-v4.jar but when I use this version, when I press home button it causes force close. I found that I should change to the newest version of support library but then, DirectionalViewPager can't import: PagerAdapter.DataSetObserver

How can I fix that?

Thanks for help.

be4code
  • 688
  • 4
  • 15

1 Answers1

0

Looks like the scope may have changed causing the DVP library to not work. See here and here for more details and work arounds.

Add the following class to your project(Make sure to have the package correctly otherwise this won't work):

package android.support.v4.view;

    public final class PagerAdapterPublicCompat {
        private PagerAdapterPublicCompat() {}

        public interface DataSetObserver extends PagerAdapter.DataSetObserver {}

        public static void setDataSetObserver(PagerAdapter adapter, DataSetObserver observer) {
            adapter.setDataSetObserver(observer);
        }
    }

then you have to set your data observer:

// from the sample code:
final DirectionalViewPager pager = (DirectionalViewPager)findViewById(R.id.pager);
pager.setAdapter(new TestFragmentAdapter(getSupportFragmentManager()));
// new addition:
PagerAdapterPublicCompat.setDataSetObserver(pager.getAdapter(), YourDataSetObserver);
Community
  • 1
  • 1
Jim Baca
  • 6,112
  • 2
  • 24
  • 30
  • When I use the .jar from the second link app does not work. And I don't know what I can get from the first one to fix app. – be4code May 10 '13 at 14:45
  • Which version of the DVP library are you using? – Jim Baca May 10 '13 at 14:47
  • It's 1.2.1, the newest possible – be4code May 10 '13 at 16:37
  • Yours class `PagerAdapterPublicCompat` is equal to `VerticalViewPagerCompat` which is currently in the library and what is `YourDataSetObserver`? I don't use any DataSetObserver. – be4code May 10 '13 at 18:54
  • Ahh. I misunderstood. I thought you were trying to and couldn't. I think they moved the DataSetObserver to android.database.DataSetObserver http://developer.android.com/reference/android/database/DataSetObserver.html. – Jim Baca May 10 '13 at 19:08
  • Maybe because my poor English. Sorry :) I've seen that DataSetObserver is moved but I don't know who to make it works. Any advice? – be4code May 10 '13 at 19:15
  • Finally, the jar from http://stackoverflow.com/a/14268702/1356669 is the sollution. I've forgotten to change from `com.directionalviewpager.DirectionalViewPager` to `android.support.v4.view.DirectionalViewPager` in my xml. – be4code May 11 '13 at 09:03