如何在Fragment中实现ViewFlipper?
我的代码如下:
public ImageView getImageView(int res_id){ ImageView imageView = new ImageView(getContext()); imageView.setBackgroundResource(res_id); return imageView; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.home_layout,container,false); ViewFlipper flipper = (ViewFlipper) view.findViewById(R.id.flipper); for (int i : image_resource){ flipper.addView(getImageView(i)); } flipper.setInAnimation(this.getContext(),R.anim.right_enter); flipper.setOutAnimation(this.getContext(),R.anim.left_out); flipper.startFlipping(); return view; }
不知道为什么没有效果,图片都不显示,也不报错.
求解答