0

I am new to android and I want to add this viewpager library https://github.com/jfeinstein10/JazzyViewPager to my project. For that I first extracted the project. And than I right clicked on my project than Build Path -> configure build path-> than I selected libraries. After that I selected Add external jar and added the library. However, The project mentions that I should make changes in my Imagedadapter. Which I did.. However, I am getting yellow bulb with red cross and I it says JazzyViewPager cannot be resolved to a variable..I believe I am doing minor mistake..but can't figure out..Please help ..Thanks in advance

Following is my Imageadapter.java

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ImageAdapter extends PagerAdapter {
    Context context;
    private int[] GalImages = new int[] {
        R.drawable.one,
        R.drawable.two,
        R.drawable.three,
        R.drawable.four,
        R.drawable.five
    };
    ImageAdapter(Context context){
        this.context=context;
    }
    @Override
    public int getCount() {
      return GalImages.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
      return view == ((ImageView) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
      ImageView imageView = new ImageView(context);
      int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_small);
      imageView.setPadding(padding, padding, padding, padding);
      imageView.setScaleType(ImageView.ScaleType. FIT_XY  );
      Resources r = context.getResources();
      Bitmap bmp = BitmapFactory.decodeResource(r, GalImages[position]);
      int width=200;//set your width
      int height=200;//set your height
      Bitmap resizedbitmap = Bitmap.createScaledBitmap(bmp, width, height, true);
      Drawable d = new BitmapDrawable(r,resizedbitmap);
      Drawable[] layers = new Drawable[2];
      layers[0] = d;
      layers[1] = r.getDrawable(R.drawable.a);
      LayerDrawable layerDrawable = new LayerDrawable(layers);
      imageView.setImageDrawable(layerDrawable);
      ((ViewPager) container).addView(imageView, 0);
      return imageView;


    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager) container).removeView((ImageView) object);
    }
    private JazzyViewPager mJazzy;
    /* ... */
    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        Object obj = super.instantiateItem(container, position);
        mJazzy.setObjectForPosition(obj, position);
        return obj;
    }
}
    }

Edited

After selecting Jazzyviewpager library

biggboss2019
  • 220
  • 3
  • 8
  • 30

2 Answers2

0

Try these:

  1. click the import button in the file menu in eclispe.
  2. select import existing projects into workspace.
  3. out in the finder window select the JazzyViewPager library.
  4. once the library is visible in your work space right click your project and select properties.
  5. go to the android option. 6.at the bottom where the library window click add.
  6. select your project.

this should work this is how you import libraries such as the facebook sdk and google play sdk if not let me know. hopes this helps.

Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58
  • ..I tried your steps..However after step3 I cannot click on finish option..please see my attach image.. – biggboss2019 Sep 12 '14 at 01:46
  • okay i will try to download it myself to try to help you out. – Will Stowers Sep 12 '14 at 02:01
  • one thing you can do is add it into your project the manual way. you will have to open the jazzypager project and go to the lib folder and copy all the files out of the src. Then you will have to add the nineoldandroids.jar that is in the lib folder to your lib folder in your and then right click the jar and select build path and then add to build path. you will also have to edit your values file to match the project's referencing files but this will allow you to add the jazzypager into your project – Will Stowers Sep 12 '14 at 02:48
0
  1. Download the library project
  2. Import it into your workspace
  3. Right click on your project, click on Properties
  4. In the "Library" section at the bottom, click on Add
  5. Select the Jazzy ListView library , click OK
An SO User
  • 24,612
  • 35
  • 133
  • 221
  • @smithhhh You need to [see this question](http://stackoverflow.com/questions/15845093/eclipse-import-existing-android-project) – An SO User Sep 12 '14 at 02:00
  • ...as suggested by 5 upvotes answers in the above link. I tried to find .classpath and .project file in my downloaded code..however, I didn't find those files.. is there Any other alternative possible ? – biggboss2019 Sep 12 '14 at 02:23
  • Create a new project first and *then* look for those files in the created project. After that, copy the files into the library project, make appropriate changes, and then import it into workspace :) – An SO User Sep 12 '14 at 02:28