具有不同视图的viewflipper
我想构建三个视图的圆圈,在每个视图上有两个按钮用于上一个和下一个视图由它们连接的所有三个视图。 我为每个视图提供了三个布局,以及三个随布局相应膨胀的 CustomView。 最重要的是一个包含 ViewFlipper 的 Activity。
我的问题是:
1.我如何使用 viewFlipper 在它们之间切换?
与 myFlipper.addView(myView) 还是我应该在 viewFlipper 布局中使用标签?
2.如何使用相关布局来扩展我的视图 我已经尝试 LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.t1, null);
我的活动看起来像这样
public class Activity1 extends Activity {
private ViewFlipper flipper;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_fliper_layout);
flipper = (ViewFlipper) findViewById(R.id.flipper);
myView1 temp1= new myView1 (this);
flipper.addView(myView1 , 1);
flipper.setDisplayedChild(1);
}
}
I want to build circle of three View,On each view two buttons to prev and next View all the three View connected by them.
I have three layout for each View, and three CustomView that inflate accordingly with the layout.
and above all one Activity that hold ViewFlipper.
my questions is:
1.how could I flip between them with viewFlipper?
with myFlipper.addView(myView) or should i use tag inside the viewFlipper layout?
2.how to inflate my view with the relevant Layout
I already try LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.t1, null);
my activity looks like this
public class Activity1 extends Activity {
private ViewFlipper flipper;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_fliper_layout);
flipper = (ViewFlipper) findViewById(R.id.flipper);
myView1 temp1= new myView1 (this);
flipper.addView(myView1 , 1);
flipper.setDisplayedChild(1);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://developer.android.com/reference/android/widget/ViewAnimator .html#showNext()
http://developer.android.com/reference/android/widget/ViewAnimator.html#showNext()
在 viewflipper 中动态添加子项。
adding child in viewflipper dyanamically.
这可能对你有帮助。
This might help you.