#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    The method setAdapter... error.


    I'm getting an error on my setAdapter.
    This line of code;
    Code:
    myPager.setAdapter(adapter);
    I'm getting a red squiggle line under setAdapter

    Thank you in advance!

    Here is my full page of code;
    Code:
    package com.example.gymbuddy;
    
    import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.os.Parcelable;
    import android.support.v4.view.ViewPager;
    import android.view.LayoutInflater;
    import android.view.View;
    
    public class Upperbody extends Activity {
    
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    	    super.onCreate(savedInstanceState);
    	    setContentView(R.layout.activity_upperbody);
    	    
    	    MyPagerAdapter adapter = new MyPagerAdapter();
    	    ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
    	    myPager.setAdapter(adapter);
    	    myPager.setCurrentItem(2); }
    	
    	public class MyPagerAdapter extends Activity {
    		 
            public int getCount() {
                return 9;
            }
     
            public Object instantiateItem(View collection, int position) {
     
                LayoutInflater inflater = (LayoutInflater) collection.getContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     
                int resId = 0;
                switch (position) {
                case 0:
                    resId = R.layout.upper0;
                    break;
                case 1:
                    resId = R.layout.upper1;
                    break;
                case 2:
                    resId = R.layout.upper2;
                    break;
                case 3:
                    resId = R.layout.upper3;
                    break;
                case 4:
                    resId = R.layout.upper4;
                    break;
                case 5:
                	resId = R.layout.upper5;
                	break;
                case 6:
                	resId = R.layout.upper6;
                	break;
                case 7:
                	resId = R.layout.upper7;
                	break;
                case 8:
                	resId = R.layout.upper8;
                	break; }
     
                View view = inflater.inflate(resId, null);
     
                ((ViewPager) collection).addView(view, 0);
     
                return view; }
            
            public void destroyItem(View arg0, int arg1, Object arg2) {
                ((ViewPager) arg0).removeView((View) arg2); }
            
            public boolean isViewFromObject(View arg0, Object arg1) {
                return arg0 == ((View) arg1); }
            
            public Parcelable saveState() {
                return null; }
            
    	}
    	
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0
    Someone has to know :\

IMN logo majestic logo threadwatch logo seochat tools logo