Android 活动在工作过程中关闭,并将其重定向到上一个活动
我创建了贷款调查应用程序。在每次调查中,显示了80到90个问题。当他按下“下一步”按钮时,问题会一个接一个地显示出来。r以编程方式创建的视图,在提交每个问题后,我已删除该视图并创建另一个视图 很好,但我的问题是, 当我在第30到40个问题中时,我的活动突然结束并重定向到上一个活动。即使它也不执行onPause方法。我不知道是什么问题。也没有应用程序崩溃。我不知道这是由于内存错误还是其他原因造成的。请任何人建议我如何解决它Android 活动在工作过程中关闭,并将其重定向到上一个活动,android,android-activity,forceclose,Android,Android Activity,Forceclose,我创建了贷款调查应用程序。在每次调查中,显示了80到90个问题。当他按下“下一步”按钮时,问题会一个接一个地显示出来。r以编程方式创建的视图,在提交每个问题后,我已删除该视图并创建另一个视图 很好,但我的问题是, 当我在第30到40个问题中时,我的活动突然结束并重定向到上一个活动。即使它也不执行onPause方法。我不知道是什么问题。也没有应用程序崩溃。我不知道这是由于内存错误还是其他原因造成的。请任何人建议我如何解决它 提前感谢以下是我结合和的答案所能达到的程度 MyAnimation.jav
提前感谢以下是我结合和的答案所能达到的程度 MyAnimation.java
package com.example.tempp;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class MyAnimation extends Animation {
private View view;
private float cx, cy; // center x,y position of circular path
private float prevX, prevY; // previous x,y position of image during animation
private float r; // radius of circle
/**
* @param view - View that will be animated
* @param r - radius of circular path
*/
public MyAnimation(View view, float r){
this.view = view;
this.r = r;
}
@Override
public boolean willChangeBounds() {
return true;
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
// calculate position of image center
int cxImage = width / 2;
int cyImage = height / 2;
cx = view.getLeft() + cxImage;
cy = view.getTop() + cyImage;
// set previous position to center
prevX = cx;
prevY = cy;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 0){
// I ran into some issue where interpolated would be
return;
}
float angleDeg = (interpolatedTime * 360f + 90) % 360;
float angleRad = (float) Math.toRadians(angleDeg);
// r = radius, cx and cy = center point, a = angle (radians)
float x = (float) (cx + r * Math.cos(angleRad));
float y = (float) (cy + r * Math.sin(angleRad));
float dx = prevX - x;
float dy = prevY - y;
prevX = x;
prevY = y;
t.getMatrix().setTranslate(dx, dy);
}
}
希望这有帮助。你是说类似的东西吗?不是那样的。。。检查上面的图片,它应该是顺时针旋转地球仪将如何在三维旋转。神秘的魔法告诉我们如何在3d中旋转。提前感谢使用您的代码,它将离开它的位置。是否要在同一位置设置图像动画?或者想要它的位置以圆周运动的方式改变?是的。以圆周运动在同一位置设置图像动画。请尝试使用我的帖子
package com.example.tempp;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class MyAnimation extends Animation {
private View view;
private float cx, cy; // center x,y position of circular path
private float prevX, prevY; // previous x,y position of image during animation
private float r; // radius of circle
/**
* @param view - View that will be animated
* @param r - radius of circular path
*/
public MyAnimation(View view, float r){
this.view = view;
this.r = r;
}
@Override
public boolean willChangeBounds() {
return true;
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
// calculate position of image center
int cxImage = width / 2;
int cyImage = height / 2;
cx = view.getLeft() + cxImage;
cy = view.getTop() + cyImage;
// set previous position to center
prevX = cx;
prevY = cy;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 0){
// I ran into some issue where interpolated would be
return;
}
float angleDeg = (interpolatedTime * 360f + 90) % 360;
float angleRad = (float) Math.toRadians(angleDeg);
// r = radius, cx and cy = center point, a = angle (radians)
float x = (float) (cx + r * Math.cos(angleRad));
float y = (float) (cy + r * Math.sin(angleRad));
float dx = prevX - x;
float dy = prevY - y;
prevX = x;
prevY = y;
t.getMatrix().setTranslate(dx, dy);
}
}