android – Image Slider using two fragment using BaseAdapter-ThrowExceptions

Exception or error:

I am completely new to android, I have just started android

I have two fragments, first one is of images grid view and when it is clicked then the image should be shown on the second fragments on full screen and also we can slide images in second fragments

and also I want to know that it can be done by BaseAdapter or not??

**mainactivity.java**

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        GridView gv=(GridView)findViewById(R.id.grid_view);
        gv.setAdapter(new ImageAdapter(this));
        gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                bottomfragment btm=new bottomfragment();
                ImageAdapter imageAdapter=new ImageAdapter(btm);
                ImageView imageView = (ImageView)findViewById(R.id.img_view);
                imageView.setImageResource(imageAdapter.thumbsImage[position]);
     }

        });

        ViewPager viewPager=(ViewPager)findViewById(R.id.view_pager);




    }


}
***imageadapter***



public class ImageAdapter extends BaseAdapter {
//    private final Object container;
    private Context mcontext;
    private LayoutInflater layoutInflater;
     int[] thumbsImage ={
            R.drawable.img1,
            R.drawable.img2,
            R.drawable.img3,
            R.drawable.img4,
            R.drawable.img5,
            R.drawable.img6,

    };

    public ImageAdapter(Context c){
        this.mcontext=c;

    }

    public ImageAdapter(bottomfragment btm) {

    }



    @Override
    public int getCount() {

        return thumbsImage.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageview=new ImageView(mcontext);
        GridLayout.LayoutParams param=new GridLayout.LayoutParams();

        param.width=400;
        param.height=400;
        imageview.setLayoutParams(param);

        imageview.setPadding(8,8,8,8);
        imageview.setScaleType(ImageView.ScaleType.CENTER);
        imageview.setImageResource(thumbsImage[position]);
        return imageview;



    }


How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *