how setup appearance animation to my listView in android?

1.2k views Asked by At

i try to add an appearance animation to my ListView. When I search on the internet i finally found this link to start. ListView appearance demo

this is my MainActivity and onCreateView

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_main);


    ArrayList<String> strings = new ArrayList<String>();
    strings.add("");
    strings.add("");
    strings.add("");
    strings.add("");
    strings.add("");
    strings.add("");

    MyListAdapter mAdapter = new MyListAdapter(this, strings);
    SwingRightInAnimationAdapter swingRightInAnimationAdapter = new SwingRightInAnimationAdapter(mAdapter);

    // Assign the ListView to the AnimationAdapter and vice versa
    ListView myListView = (ListView) findViewById(R.id.myListView);
    swingRightInAnimationAdapter.setAbsListView(myListView);
    myListView.setAdapter(swingRightInAnimationAdapter);
}

But when i launch this simple sample project an error rises with this content:

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.nineoldandroids.animation.Animator[]

I download the jar lib and use it in build.gradle in android studio

repositories {
mavenCentral()}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/listviewanimations_lib-core_3.1.0.jar')}

help me if it's possible thanks

2

There are 2 answers

6
Dion Segijn On BEST ANSWER

You miss the NineOldAndroids jar in your project to make this library work. You can download it here: https://github.com/JakeWharton/NineOldAndroids/downloads

And as Joel stated in the comments you don't need to add the jars to your compile file since compile fileTree(dir: 'libs', include: ['*.jar']) takes care of that.

You can also do this without any jar files. Sync in android studio with an repository like this:

repositories {
   mavenCentral()
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
  compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
}

You can check more dependencies to compile for this library on this page: https://github.com/nhaarman/ListViewAnimations

0
Adnan Mulla On

You don't have nineOldAndroids jar in your project.

Download the jar files you need: lib-core lib-manipulation lib-core-slh Download the latest NineOldAndroids .jar file

Add the .jar files to your project's libs folder, or add them as external jars to your project's build path.

Please read the Readme of the github project