public class OneFgm extends Fragment{
private int[] image_resource = {
R.drawable.abookapart1,
R.drawable.bg2015071003,
R.drawable.bg2015071004,
R.drawable.bg2015071010
};
public OneFgm() {
}
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;
}
}不知道为什么没有效果,甚至连图都没有..
添加回答
举报
0/150
提交
取消