Android 布局翻转/转动在 logcat 中显示错误
我是安卓新手。在谷歌上进行了一些搜索后,我尝试了一个动画程序,并在模拟器中强制关闭,并且在运行项目时不显示任何内容,
我希望对两个布局(xml文件)(即signin.xml和)有翻转/转动效果注册.xml。单击signin.xml 中的新用户按钮,我想将布局转换为register.xml
我采用了两种布局并尝试实现,即线性布局和表格布局。这是我遵循的正确程序吗?
我添加了单个按钮进行试用,但它不起作用,我想知道这段代码有什么问题,
我没有收到任何错误,但运行时模拟器出现问题。
请有人帮助我,...谢谢!
这些 r 我的 xml 文件
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/Layout01"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:background="@drawable/loginapp">
<Button android:layout_width="49px" android:layout_height="44px" android:background="@drawable/login_home_btn_over_green" android:id="@+id/widget38"></Button>
</LinearLayout>
<RelativeLayout android:id="@+id/relativeLayout1" android:gravity="center" android:layout_marginTop="25dip" android:layout_height="177dip" android:background="@drawable/login_form_bg_green" android:layout_width="296dip">
<EditText android:layout_marginRight="0dip" android:id="@+id/userNameBox" android:layout_width="200px" android:background="@android:drawable/editbox_background" android:maxLines="1" android:layout_marginLeft="85dip" android:inputType="text" android:layout_height="wrap_content"></EditText>
<EditText android:layout_marginRight="0dip" android:id="@+id/passwordBox" android:layout_width="200px" android:background="@android:drawable/editbox_background" android:maxLines="1" android:layout_marginTop="45dip" android:layout_marginLeft="85dip" android:inputType="text|textVisiblePassword" android:layout_height="wrap_content"></EditText>
</RelativeLayout>
<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_two" android:gravity="center">
<Button
android:text="Sign In"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginRight="15dip"
android:layout_height="wrap_content"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="5dip"
android:id="@+id/Button02"
android:text="New user"/>
</LinearLayout>
</LinearLayout>
register.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/Layout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow>
<TextView android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" REGISTER:"/>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:background="@android:drawable/editbox_background"
android:maxLines="1" android:layout_marginLeft="15dip" android:layout_weight="1"
android:inputType="text" android:layout_height="35px" android:layout_width="0dip"></EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:layout_width="200px" android:layout_weight="1"
android:background="@android:drawable/editbox_background" android:maxLines="1"
android:layout_marginLeft="15dip" android:inputType="text"
android:layout_height="35px"></EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email:"/>
<EditText
android:id="@+id/userNameBox" android:layout_width="200px"
android:background="@android:drawable/editbox_background" android:layout_weight="1"
android:maxLines="1" android:layout_marginLeft="15dip" android:layout_marginRight="0dip"
android:inputType="text" android:layout_height="35px">
</EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile No:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:layout_width="200px" android:layout_weight="1"
android:background="@android:drawable/editbox_background"
android:maxLines="1" android:layout_marginLeft="15dip"
android:inputType="text" android:layout_height="35px">
</EditText>
</TableRow>
<TableRow>
<Button
android:layout_height="wrap_content"
android:text="Register"
android:id="@+id/Button03"
android:padding="3dip"
android:layout_marginLeft="45dip"
android:layout_marginRight="90dip"
android:layout_marginTop="15dip"
android:layout_column="1"
android:layout_width="fill_parent"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
Flip3d.java
package com.animation;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public class Flip3d extends Activity {
private LinearLayout layout01;
private TableLayout layout02;
private boolean isFirstLayout = true;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button newuser =(Button)findViewById(R.id.Button02);
layout01 = (LinearLayout) findViewById(R.id.Layout01);
layout02 = (TableLayout) findViewById(R.id.Layout02);
layout02.setVisibility(View.GONE);
newuser.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (isFirstLayout) {
applyRotation(0, 90);
isFirstLayout = !isFirstLayout;
} else {
applyRotation(0, -90);
isFirstLayout = !isFirstLayout;
}
}
});
}
private void applyRotation(float start, float end) {
// Find the center of image
final float centerX = layout01.getWidth() / 2.0f;
final float centerY = layout01.getHeight() / 2.0f;
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final FlipAnimation rotation =
new FlipAnimation(start, end, centerX, centerY);
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new DisplayNextView(isFirstLayout, layout01, layout02));
if (isFirstLayout)
{
layout01.startAnimation(rotation);
} else {
layout02.startAnimation(rotation);
}
}
public void setLayout01(LinearLayout layout01) {
this.layout01 = layout01;
}
public LinearLayout getLayout01() {
return layout01;
}
public void setLayout02(TableLayout layout02) {
this.layout02 = layout02;
}
public TableLayout getLayout02() {
return layout02;
}
}
Flipanimation.java
package com.animation;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class FlipAnimation extends Animation {
private final float mFromDegrees;
private final float mToDegrees;
private final float mCenterX;
private final float mCenterY;
private Camera mCamera;
public FlipAnimation(float fromDegrees, float toDegrees,
float centerX, float centerY) {
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mCenterX = centerX;
mCenterY = centerY;
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mCamera = new Camera();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
}
Displaynextview.java
package com.animation;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public final class DisplayNextView implements Animation.AnimationListener {
private boolean mCurrentView;
LinearLayout layout01;
TableLayout layout02;
public DisplayNextView(boolean isFirstLayout, LinearLayout layout01,
TableLayout layout02) {
mCurrentView = isFirstLayout;
this.layout01 = layout01;
this.layout02 = layout02;
}
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
layout01.post(new SwapViews(mCurrentView, layout01, layout02));
}
public void onAnimationRepeat(Animation animation) {
}
swapview.java
package com.animation;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public final class SwapViews implements Runnable {
private boolean mIsFirstView;
LinearLayout layout01;
TableLayout layout02;
public SwapViews(boolean isFirstLayout, LinearLayout layout01, TableLayout layout02) {
mIsFirstView = isFirstLayout;
this.layout01 = layout01;
this.layout02 = layout02;
}
public void run() {
final float centerX = layout01.getWidth() / 2.0f;
final float centerY = layout02.getHeight() / 2.0f;
FlipAnimation rotation;
if (mIsFirstView) {
layout01.setVisibility(View.GONE);
layout02.setVisibility(View.VISIBLE);
layout02.requestFocus();
rotation = new FlipAnimation(-90, 0, centerX, centerY);
} else {
layout02.setVisibility(View.GONE);
layout01.setVisibility(View.VISIBLE);
layout01.requestFocus();
rotation = new FlipAnimation(90, 0, centerX, centerY);
}
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new DecelerateInterpolator());
if (mIsFirstView) {
layout02.startAnimation(rotation);
} else {
layout01.startAnimation(rotation);
}
}
}
Flip.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/notelist" layout="@layout/main" />
<include android:id="@+id/notelist" layout="@layout/register" />
</FrameLayout>
这些 r LOGCAT 04-26 12:48:27.877 中的错误
:INFO/ActivityManager(57): Start proc com.animation 用于活动 com.animation/.Login:pid=294 uid=10047 gids={} 04-26 12:48:27.887:DEBUG/AndroidRuntime(276):关闭虚拟机 04-26 12:48:27.947: 调试/jdwp(276): adbd 已断开连接 04-26 12:48:27.988: INFO/AndroidRuntime(276): 注意:附加线程“Binder Thread #3”失败 04-26 12:48:28.647:DEBUG/AndroidRuntime(294):关闭虚拟机 04-26 12:48:28.657:警告/dalvikvm(294):threadid = 1:线程因未捕获的异常而退出(组= 0x4001d800) 04-26 12:48:28.697:错误/AndroidRuntime(294):致命异常:主要 04-26 12:48:28.697:错误/AndroidRuntime(294):java.lang.RuntimeException:无法实例化活动ComponentInfo {com.animation / com.animation.Login}:java.lang.ClassNotFoundException:com.animation.Login在加载器 dalvik.system.PathClassLoader[/data/app/com.animation-1.apk] 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.ActivityThread.access $ 2300(ActivityThread.java:125) 04-26 12:48:28.697:错误/AndroidRuntime(294):在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.os.Handler.dispatchMessage(Handler.java:99) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.os.Looper.loop(Looper.java:123) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.ActivityThread.main(ActivityThread.java:4627) 04-26 12:48:28.697:错误/AndroidRuntime(294):在java.lang.reflect.Method.invokeNative(本机方法) 04-26 12:48:28.697:错误/AndroidRuntime(294):在java.lang.reflect.Method.invoke(Method.java:521) 04-26 12:48:28.697:错误/AndroidRuntime(294):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 04-26 12:48:28.697:错误/AndroidRuntime(294):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-26 12:48:28.697:错误/AndroidRuntime(294):在dalvik.system.NativeStart.main(本机方法) 04-26 12:48:28.697:错误/AndroidRuntime(294):引起:java.lang.ClassNotFoundException:com.animation.Login加载器dalvik.system.PathClassLoader [/data/app/com.animation-1.apk ] 04-26 12:48:28.697:错误/AndroidRuntime(294):在dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 04-26 12:48:28.697:错误/AndroidRuntime(294):在java.lang.ClassLoader.loadClass(ClassLoader.java:573) 04-26 12:48:28.697:错误/AndroidRuntime(294):在java.lang.ClassLoader.loadClass(ClassLoader.java:532) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.Instrumentation.newActivity(Instrumentation.java:1021) 04-26 12:48:28.697:错误/AndroidRuntime(294):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 04-26 12:48:28.697: 错误/AndroidRuntime(294): ... 11 更多 04-26 12:48:28.757: WARN/ActivityManager(57): 强制完成活动 com.animation/.Login 04-26 12:48:29.267: WARN/ActivityManager(57): HistoryRecord{43fe6f90 com.animation/.Login} 的活动暂停超时 04-26 12:48:39.376: WARN/ActivityManager(57): HistoryRecord{43fe6f90 com.animation/.Login} 的活动销毁超时 04-26 12:48:44.548:调试/KeyguardViewMediator(57):pokeWakelock(5000) 04-26 12:48:44.658:调试/KeyguardViewMediator(57):pokeWakelock(5000) 04-26 12:48:44.888: WARN/WindowManager(57): 没有窗口可以调度指针操作 1 04-26 12:48:44.958:INFO / ARAssembler(57):在5876460 ns内的[0x360da0:0x360f68]处生成扫描线__00000177:03515104_00001001_00000000 [91 ipp](114 ins) 04-26 12:48:45.018:信息/ARMAssembler(57):在606224 ns内的[0x360f70:0x36102c]处生成扫描线__00000077:03515104_00000000_00000000 [33 ipp](47英寸) 04-26 12:48:49.278:信息/进程(294):发送信号。 PID:294 SIG:9 04-26 12:48:49.288:INFO/ActivityManager(57):进程 com.animation (pid 294) 已死亡。
I am newbie to android. After a bit of search in google I tried an animation program and its closing in the emulator forcefully and not showing any thing while running the project
I want to have a flip/turn effect for two layouts(xml files) i.e for signin.xml and register.xml. With single click on new-user button in signin.xml I want to turn the layout to register.xml
I have taken two layouts and tried to implement, i.e Linear and table layouts. Is it the right procedure what I followed
I have added single button for a trial, but its not working and I want to know whats the wrong with this code
I am getting no errors but problem with emulator while running.
plz some one help me,...Thanks!
these r my xml files
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/Layout01"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:background="@drawable/loginapp">
<Button android:layout_width="49px" android:layout_height="44px" android:background="@drawable/login_home_btn_over_green" android:id="@+id/widget38"></Button>
</LinearLayout>
<RelativeLayout android:id="@+id/relativeLayout1" android:gravity="center" android:layout_marginTop="25dip" android:layout_height="177dip" android:background="@drawable/login_form_bg_green" android:layout_width="296dip">
<EditText android:layout_marginRight="0dip" android:id="@+id/userNameBox" android:layout_width="200px" android:background="@android:drawable/editbox_background" android:maxLines="1" android:layout_marginLeft="85dip" android:inputType="text" android:layout_height="wrap_content"></EditText>
<EditText android:layout_marginRight="0dip" android:id="@+id/passwordBox" android:layout_width="200px" android:background="@android:drawable/editbox_background" android:maxLines="1" android:layout_marginTop="45dip" android:layout_marginLeft="85dip" android:inputType="text|textVisiblePassword" android:layout_height="wrap_content"></EditText>
</RelativeLayout>
<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_two" android:gravity="center">
<Button
android:text="Sign In"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginRight="15dip"
android:layout_height="wrap_content"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="5dip"
android:id="@+id/Button02"
android:text="New user"/>
</LinearLayout>
</LinearLayout>
register.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/Layout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow>
<TextView android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" REGISTER:"/>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Name:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:background="@android:drawable/editbox_background"
android:maxLines="1" android:layout_marginLeft="15dip" android:layout_weight="1"
android:inputType="text" android:layout_height="35px" android:layout_width="0dip"></EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Name:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:layout_width="200px" android:layout_weight="1"
android:background="@android:drawable/editbox_background" android:maxLines="1"
android:layout_marginLeft="15dip" android:inputType="text"
android:layout_height="35px"></EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email:"/>
<EditText
android:id="@+id/userNameBox" android:layout_width="200px"
android:background="@android:drawable/editbox_background" android:layout_weight="1"
android:maxLines="1" android:layout_marginLeft="15dip" android:layout_marginRight="0dip"
android:inputType="text" android:layout_height="35px">
</EditText>
</TableRow>
<TableRow>
<TextView android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile No:"/>
<EditText android:layout_marginRight="0dip"
android:id="@+id/userNameBox" android:layout_width="200px" android:layout_weight="1"
android:background="@android:drawable/editbox_background"
android:maxLines="1" android:layout_marginLeft="15dip"
android:inputType="text" android:layout_height="35px">
</EditText>
</TableRow>
<TableRow>
<Button
android:layout_height="wrap_content"
android:text="Register"
android:id="@+id/Button03"
android:padding="3dip"
android:layout_marginLeft="45dip"
android:layout_marginRight="90dip"
android:layout_marginTop="15dip"
android:layout_column="1"
android:layout_width="fill_parent"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
flip3d.java
package com.animation;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public class Flip3d extends Activity {
private LinearLayout layout01;
private TableLayout layout02;
private boolean isFirstLayout = true;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button newuser =(Button)findViewById(R.id.Button02);
layout01 = (LinearLayout) findViewById(R.id.Layout01);
layout02 = (TableLayout) findViewById(R.id.Layout02);
layout02.setVisibility(View.GONE);
newuser.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (isFirstLayout) {
applyRotation(0, 90);
isFirstLayout = !isFirstLayout;
} else {
applyRotation(0, -90);
isFirstLayout = !isFirstLayout;
}
}
});
}
private void applyRotation(float start, float end) {
// Find the center of image
final float centerX = layout01.getWidth() / 2.0f;
final float centerY = layout01.getHeight() / 2.0f;
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final FlipAnimation rotation =
new FlipAnimation(start, end, centerX, centerY);
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new DisplayNextView(isFirstLayout, layout01, layout02));
if (isFirstLayout)
{
layout01.startAnimation(rotation);
} else {
layout02.startAnimation(rotation);
}
}
public void setLayout01(LinearLayout layout01) {
this.layout01 = layout01;
}
public LinearLayout getLayout01() {
return layout01;
}
public void setLayout02(TableLayout layout02) {
this.layout02 = layout02;
}
public TableLayout getLayout02() {
return layout02;
}
}
Flipanimation.java
package com.animation;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class FlipAnimation extends Animation {
private final float mFromDegrees;
private final float mToDegrees;
private final float mCenterX;
private final float mCenterY;
private Camera mCamera;
public FlipAnimation(float fromDegrees, float toDegrees,
float centerX, float centerY) {
mFromDegrees = fromDegrees;
mToDegrees = toDegrees;
mCenterX = centerX;
mCenterY = centerY;
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mCamera = new Camera();
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
final float centerX = mCenterX;
final float centerY = mCenterY;
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
}
Displaynextview.java
package com.animation;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public final class DisplayNextView implements Animation.AnimationListener {
private boolean mCurrentView;
LinearLayout layout01;
TableLayout layout02;
public DisplayNextView(boolean isFirstLayout, LinearLayout layout01,
TableLayout layout02) {
mCurrentView = isFirstLayout;
this.layout01 = layout01;
this.layout02 = layout02;
}
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
layout01.post(new SwapViews(mCurrentView, layout01, layout02));
}
public void onAnimationRepeat(Animation animation) {
}
swapview.java
package com.animation;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TableLayout;
public final class SwapViews implements Runnable {
private boolean mIsFirstView;
LinearLayout layout01;
TableLayout layout02;
public SwapViews(boolean isFirstLayout, LinearLayout layout01, TableLayout layout02) {
mIsFirstView = isFirstLayout;
this.layout01 = layout01;
this.layout02 = layout02;
}
public void run() {
final float centerX = layout01.getWidth() / 2.0f;
final float centerY = layout02.getHeight() / 2.0f;
FlipAnimation rotation;
if (mIsFirstView) {
layout01.setVisibility(View.GONE);
layout02.setVisibility(View.VISIBLE);
layout02.requestFocus();
rotation = new FlipAnimation(-90, 0, centerX, centerY);
} else {
layout02.setVisibility(View.GONE);
layout01.setVisibility(View.VISIBLE);
layout01.requestFocus();
rotation = new FlipAnimation(90, 0, centerX, centerY);
}
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new DecelerateInterpolator());
if (mIsFirstView) {
layout02.startAnimation(rotation);
} else {
layout01.startAnimation(rotation);
}
}
}
flip.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/notelist" layout="@layout/main" />
<include android:id="@+id/notelist" layout="@layout/register" />
</FrameLayout>
these r the errors in LOGCAT
04-26 12:48:27.877: INFO/ActivityManager(57): Start proc com.animation for activity com.animation/.Login: pid=294 uid=10047 gids={}
04-26 12:48:27.887: DEBUG/AndroidRuntime(276): Shutting down VM
04-26 12:48:27.947: DEBUG/jdwp(276): adbd disconnected
04-26 12:48:27.988: INFO/AndroidRuntime(276): NOTE: attach of thread 'Binder Thread #3' failed
04-26 12:48:28.647: DEBUG/AndroidRuntime(294): Shutting down VM
04-26 12:48:28.657: WARN/dalvikvm(294): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): FATAL EXCEPTION: main
04-26 12:48:28.697: ERROR/AndroidRuntime(294): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.animation/com.animation.Login}: java.lang.ClassNotFoundException: com.animation.Login in loader dalvik.system.PathClassLoader[/data/app/com.animation-1.apk]
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): Caused by: java.lang.ClassNotFoundException: com.animation.Login in loader dalvik.system.PathClassLoader[/data/app/com.animation-1.apk]
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-26 12:48:28.697: ERROR/AndroidRuntime(294): ... 11 more
04-26 12:48:28.757: WARN/ActivityManager(57): Force finishing activity com.animation/.Login
04-26 12:48:29.267: WARN/ActivityManager(57): Activity pause timeout for HistoryRecord{43fe6f90 com.animation/.Login}
04-26 12:48:39.376: WARN/ActivityManager(57): Activity destroy timeout for HistoryRecord{43fe6f90 com.animation/.Login}
04-26 12:48:44.548: DEBUG/KeyguardViewMediator(57): pokeWakelock(5000)
04-26 12:48:44.658: DEBUG/KeyguardViewMediator(57): pokeWakelock(5000)
04-26 12:48:44.888: WARN/WindowManager(57): No window to dispatch pointer action 1
04-26 12:48:44.958: INFO/ARMAssembler(57): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x360da0:0x360f68] in 5876460 ns
04-26 12:48:45.018: INFO/ARMAssembler(57): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x360f70:0x36102c] in 606224 ns
04-26 12:48:49.278: INFO/Process(294): Sending signal. PID: 294 SIG: 9
04-26 12:48:49.288: INFO/ActivityManager(57): Process com.animation (pid 294) has died.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经在模拟器上检查了您的代码并且它现在正在运行。您必须首先更改flip3d.java中包含的布局名称
,然后将main.xml和register.xml的实际布局内容复制到flip.xml itslef中,而不是使用include标签包含它们。模拟器似乎无法以这种方式处理布局包含。
I have checked your code on emulator and its working now. You have to first change the included layout name in flip3d.java
Then you copy the actual layout contents of main.xml and register.xml into flip.xml itslef instead of including them using include tag. It seems emulator cant handle layout inclusion this way.