如何为我的adapterviewflipper 创建一个onitemclicklistener?这是我的 viewflipper 适配器类中的 getView 方法:
@Override
public View getView(int position, View view, ViewGroup viewGroup)
{
view = inflater.inflate(R.layout.activity_viewflipper_content, null, false);
if (view == null)
{
view = inflater.inflate(R.layout.activity_viewflipper_content, null, false);
}
else
{
ImageView pic = view.findViewById(R.id.imgflip1xml);
TextView title = view.findViewById(R.id.textflipxml);
title.setText(postList.get(position).getTitle());
RequestOptions glideOptions = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.glideloading)
.error(R.drawable.gliderror);
Glide.with(view.getContext())
.load(postList.get(position).getPic())
.apply(glideOptions)
.into(pic);
notifyDataSetChanged();
}
return view;
}
这是我的 MainActivity:
private AdapterViewFlipper adapterViewFlipper;
adapterViewFlipper = findViewById(R.id.adapter_view_flipper_xml);
adapterViewFlipper.setFlipInterval(2000);
adapterViewFlipper.startFlipping();
flipperAdapter = new FlipperAdapter(getApplicationContext());
flipperAdapter.setTitle(flipperList);
adapterViewFlipper.setAdapter(flipperAdapter);
我想通过单击 viewflipper 的项目来进行另一项活动。