机器人:我可以使用不同类viewflipper不同的孩子 [英] android: Can i use different class for different child of viewflipper

查看:84
本文介绍了机器人:我可以使用不同类viewflipper不同的孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的屏幕在Android应用程序的工作。 我使用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);
  }
 });   
}

但节目运行异常 java.lang.RuntimeException的:无法启动的活动ComponentInfo 任何人都可以请帮我看看 是getCurrentFocus()是正确的方式来获得的看法?

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?

我尝试实现是

  • 在我需要用不同的类来定义,听看鳍每个孩子的控制
  • 在上面的例子中的主屏幕是来看我的鳍状肢的子屏幕之一
  • 而行 v.findViewById 是显示错误的我认为getCurrentFocus()是不是送的观点的正确方法
  • 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

我不知道天气我正在朝着正确的方法是什么?当我定义和收听viewflipper在类的所有儿童的所有控件在那里我定义viewflpper,该类变得非常大。这让我觉得如此..

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..

谢谢...

推荐答案

U可以使用意图亲热动画:

U can perfrom animation using Intent to:

第一步:在乌拉圭回合的项目中创建资源目录下阿尼姆文件夹

Step1: create anim folder under res directory in ur project.

第二步:创建一个slideleft.xml文件

Step2: create an slideleft.xml file

第三步:在该文件中键入以下code

Step3: type the following code in that file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromXDelta="100%p" android:toXDelta="0"
        android:duration="400" />
</set>

第4步:同样创造slideright.xml

step 4: similarly create slideright.xml

STEP5:用上面的code,但更改以下

step5: use the above code, but change the following

<translate android:fromXDelta="-100%p" android:toXDelta="0"
            android:duration="400" />

步骤6:

 target.startAnimation(AnimationUtils.loadAnimation(HomeScreen.this, R.anim.slide_left));

perfroming淡入操作,只需添加以下code在fadein.xml文件

perfroming fadein operation, just add the following code in fadein.xml file

<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0"
       android:duration="300" />

同样,对于淡出过

similarly for fade out too

<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="1.0" android:toAlpha="0.0"
       android:duration="300" />

这篇关于机器人:我可以使用不同类viewflipper不同的孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆