android:我可以为 viewflipper 的不同子级使用不同的类吗
我有不同的屏幕可以在 Android 应用程序中工作。 我为此使用 ViewFlipper。 我决定对不同的视图子级使用不同的类
public main extends Activity{
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_in);
ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
HomeScreen s = new HomeScreen(getApplicationContext(), getCurrentFocus(), viewFlipper);
}
}
,主屏幕类是:-
public class HomeScreen {
private Button signIn;
private Button createAccount;
private View v;
private Context context;
private ViewFlipper viewflipper;
public HomeScreen(Context context,View v,ViewFlipper viewflipper ) {
this.v=v;
this.context = context;
this.viewflipper = viewflipper;
signIn = (Button) v.findViewById(R.id.button_sign_in_homeScreen);
createAccount = (Button)v.findViewById(R.id.button_createAccount_homeScreen);
signIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
viewflipper.setDisplayedChild(1);
}
});
}
但显示运行异常 java.lang.RuntimeException:无法启动活动 ComponentInfo 谁能帮帮我吗
getCurrentFocus() 是获取视图的正确方法吗?
我尝试实现的是
- 我需要使用不同的类来定义、监听视图翻转器的每个子视图的控件
- 在上面的示例中,HomeScreen是我的视图翻转器的子屏幕之一
- 但是行< code>v.findViewById 显示错误我认为 getCurrentFocus() 不是发送视图的正确方式
我不知道我正在以正确的方式移动?当我在定义 viewflpper 的类中定义并监听 viewflipper 的所有子级的所有控件时,该类变得非常大。这让我这么想。。
谢谢。
I have different screen to work in an android application.
I'm using ViewFlipper for this.
I decided to used different class for different view children
public main extends Activity{
{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_in);
ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
HomeScreen s = new HomeScreen(getApplicationContext(), getCurrentFocus(), viewFlipper);
}
}
and this the Homescreen class is :-
public class HomeScreen {
private Button signIn;
private Button createAccount;
private View v;
private Context context;
private ViewFlipper viewflipper;
public HomeScreen(Context context,View v,ViewFlipper viewflipper ) {
this.v=v;
this.context = context;
this.viewflipper = viewflipper;
signIn = (Button) v.findViewById(R.id.button_sign_in_homeScreen);
createAccount = (Button)v.findViewById(R.id.button_createAccount_homeScreen);
signIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
viewflipper.setDisplayedChild(1);
}
});
}
but is shows run exception
java.lang.RuntimeException: Unable to start activity ComponentInfo
Can anyone please help me
is getCurrentFocus() is the correct way to get the view?
What i try to implement is
- I need to use different class for defining, listening the controls of each child of view flipper
- In the above example HomeScreen is one of my the child screen of view flipper
- But the line
v.findViewById
is showing error i think that getCurrentFocus() is not the correct way to sent the view
I don't know weather i'm moving in the correct way? When i define and listen all the controls of all children of viewflipper in the Class where i define that viewflpper, that class become very big. That made me to think so..
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Intent 执行动画:
步骤 1:在项目的 res 目录下创建 anim 文件夹。
步骤2:创建一个slideleft.xml文件
步骤3:在该文件中键入以下代码
步骤4:类似地创建slideright.xml
步骤5:使用上面的代码,但更改以下
步骤6:
执行淡入淡出操作,只需在淡入淡出中添加以下代码即可.xml 文件
也同样用于淡出
U can perfrom animation using Intent to:
Step1: create anim folder under res directory in ur project.
Step2: create an slideleft.xml file
Step3: type the following code in that file
step 4: similarly create slideright.xml
step5: use the above code, but change the following
step 6:
perfroming fadein operation, just add the following code in fadein.xml file
similarly for fade out too