我正在尝试使用寻呼机适配器中的else来更改字符串数组项,但是每当我启动我的应用程序时,它都会给出异常。它给出了此错误The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count.
这是我的代码
@Override
public Object instantiateItem(ViewGroup container, int position)
{
if (getIntent().getStringExtra("love")!=null)
{
icons=getResources().getStringArray(R.array.love);
}
else if (getIntent().getStringExtra("sad")!=null)
{
icons=getResources().getStringArray(R.array.sad);
}
Context context=Love.this;
mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = mLayoutInflater.inflate(R.layout.imagew, container, false);
ImageView imageView = itemView.findViewById(R.id.imageview);
random = new Random();
prevInts = new ArrayList<>();
Picasso.get().load(icons[randomUniqueInteger()]).placeholder(R.drawable.loading).error(R.drawable.loading).into(imageView);
container.addView(itemView);
return itemView;
}