如何使CarouselView在我的应用程序上显示图像

时间:2019-01-06 20:39:03

标签: java android xml

在编码时遇到麻烦,无法在我的应用程序中显示图像,它在之前运行得很好,但是在向代码中添加制表符和片段之后,一切都向南

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.synnapps.carouselview.CarouselView;
import com.synnapps.carouselview.ImageListener;

public class Home extends AppCompatActivity {

    CarouselView carouselView;

    int[] _homeImage = {R.drawable.animals, R.drawable.bigfalls, R.drawable.soca, R.drawable.towncity, R.drawable._resort};

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout._home);

        carouselView = (CarouselView) findViewById(R.id.carouselview);
        carouselView.setPageCount(_homeImage.length);

        carouselView.setImageListener(_imageListener);

    }

    ImageListener _imageListener = new ImageListener() {
        @Override
        public void setImageForPosition(int position, ImageView imageView) {
            imageView.setImageResource(_homeImage[position]);
        }
    };
}

0 个答案:

没有答案