2 u013538630 u013538630 于 2014.08.01 09:38 提问

android开发,遇到了Fatal signal 11 (SIGSEGV)

具体报错是 Fatal signal 11 (SIGSEGV) at 0x000000000 (code=1), thread 5761

public class MainActivity extends Activity implements OnGestureListener {

    ViewFlipper flipper;
    GestureDetector detector;
    Animation[] animations=new Animation[4];
    final int FLIP_DISTANCE=50;

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        detector=new GestureDetector(this, this);
        flipper=(ViewFlipper)findViewById(R.id.flipper);
        flipper.addView(addImageView(R.drawable.xjf1));
        flipper.addView(addImageView(R.drawable.xjf2));
        flipper.addView(addImageView(R.drawable.xjf3));
        flipper.addView(addImageView(R.drawable.xjf4));
        flipper.addView(addImageView(R.drawable.xjf5));
        animations[0]=AnimationUtils.loadAnimation(this,  R.anim.left_in);
        animations[1]=AnimationUtils.loadAnimation(this,R.anim.left_out);
        animations[2]=AnimationUtils.loadAnimation(this,R.anim.right_in);
        animations[3]=AnimationUtils.loadAnimation(this,R.anim.right_out);
    }

    private View addImageView(int resId) {
        // TODO Auto-generated method stub

        ImageView imageView=new ImageView(this);
        imageView.setImageResource(resId);
        imageView.setScaleType(ImageView.ScaleType.CENTER);
        return imageView;
    }
    @Override
    public boolean onTouchEvent(MotionEvent event){
        return detector.onTouchEvent(event);
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        // TODO Auto-generated method stub

        if(e1.getX()-e2.getX()>FLIP_DISTANCE){
            flipper.setInAnimation(animations[0]);
            flipper.setOutAnimation(animations[1]);
            flipper.showPrevious();
            return true;
        }else if(e2.getX()-e1.getX()>FLIP_DISTANCE){
            flipper.setInAnimation(animations[2]);
            flipper.setOutAnimation(animations[3]);
            flipper.showNext();
            return true;
        }

        return false;
    }
}   

这是主要代码,实现的是用手势切换图片,在手机上就会报以上错误,但是在我的平板上可以正常运行,貌似和内存有点关系

4个回答

u011444486
u011444486   2015.05.29 14:41

解决了?LZ,我也遇到类似问题,表示无能为力呀,我是用ViewPager+Fragment切换网络图片

q3733353520
q3733353520   2015.06.18 18:33

错误信息太少了,不知道你是什么地方出的段错误

q3733353520
q3733353520   2015.06.18 18:33

你可以多打印几句反正程序也不多,看是那一句出的问题

lly4321lly
lly4321lly   2015.12.30 15:30

我也遇到了同样的问题 求解决啊

Csdn user default icon
上传中...
上传图片
插入图片