AdapterView Flipper is not working.

Asked 2 years ago, Updated 2 years ago, 24 views

I'd like to have 4 images converted automatically.

(with auto-conversion for 2 seconds to android:flipInterval="2000" in xml)

Put four drawable images in the main_flyer_items.

I'm using it right out of the adapter (internal class).

Can I run the app, but I can't see the image.

No other classes or activities exist.


main_fliper_items = new ArrayList<Integer>();
        for (int i = 0; i < 4; i++) {
            main_fliper_items.add(getResources().getIdentifier("fliper" + i, "drawable", this.getPackageName()));
        }

adapterViewFlipper = (AdapterViewFlipper) findViewById(R.id.main_filpper);
adapterViewFlipper.setAdapter(new MainFlipperAdapter(this));
adapterViewFlipper.startFlipping();
private class MainFlipperAdapter extends BaseAdapter {

        Context context;
        LayoutInflater inflater;

        public MainFlipperAdapter(Context context) {
            this.context = context;
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
        @Override
        public int getCount() {
            return main_fliper_items.size();
        }
        @Override
        public Object getItem(int position) {
            return position;
        }
        @Override
        public long getItemId(int position) {
            return position;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if(convertView == null){
                convertView = inflater.inflate(R.layout.main_fliper_item, parent, false);
            }
            ImageView item = (ImageView) convertView.findViewById(R.id.main_filper_item);
            //Put 4 drawable images in main_flyer_items above
            item.setImageResource(main_fliper_items.get(position));
            return convertView;
        }
    }

adapterviewflipper android

2022-09-21 17:43

1 Answers

I solved it. The image names are... xx1, xx2... The image was not printed because it started with 0 in the for statement


2022-09-21 17:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.