问题描述
- 【Android开发】如何在tab选项卡标签页添加手势滑动ViewFlipper
- 如何在tab选项卡标签页添加手势滑动ViewFlipper,我在包中的一个main.java中写了添加了A的选项卡代码,在另一个A.java中加载了A的XML界面,然后我想在A中添加手势滑动翻页的功能,我尝试在A.java中添加ViewFlipper,但出现了这种情况
部分代码如下:
final int FLIP_DISTANCE = 50;
ViewFlipper flipper;
GestureDetector detector;
Animation[] anim=new Animation[4];@Overrideprotected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.layout_article); detector=new GestureDetector(this); flipper=(ViewFlipper)findViewById(R.id.f1); flipper.addView(addView(R.layout.layout_acticle1)); anim[0]=AnimationUtils.loadAnimation(this R.anim.left_in); anim[1]=AnimationUtils.loadAnimation(this R.anim.left_out); anim[2]=AnimationUtils.loadAnimation(this R.anim.rigt_in); anim[3]=AnimationUtils.loadAnimation(this R.anim.rigt_out);}private View addView(int layout) { LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view=inflater.inflate(layout null); return view;}
时间: 2024-11-02 08:38:20