Android 安卓:图像不会出现

Android 安卓:图像不会出现,android,imageview,Android,Imageview,我的ImageView有一个问题,我不能查看我的图像,我想让我的应用程序完美地工作。有人能帮我吗:) 代码: 对不起,我的英语不好 您无法看到图像,因为您正在将drawable设置为null。删除这行代码,它就会工作。建议您不要使用get drawable,因为该方法存在内存泄漏,因此您应该使用setImageResource方法,而不要使用Thread.sleep来延迟。这将使UI线程休眠并挂起应用程序。尝试: 我想你需要使用RunNuithRead。你希望图像在500毫秒内保持在屏幕上,然后

我的ImageView有一个问题,我不能查看我的图像,我想让我的应用程序完美地工作。有人能帮我吗:)

代码:


对不起,我的英语不好

您无法看到图像,因为您正在将drawable设置为null。删除这行代码,它就会工作。建议您不要使用get drawable,因为该方法存在内存泄漏,因此您应该使用setImageResource方法,而不要使用Thread.sleep来延迟。这将使UI线程休眠并挂起应用程序。尝试:


我想你需要使用RunNuithRead。你希望图像在500毫秒内保持在屏幕上,然后消失吗?我只希望图像闪烁。
...
ImageView myimage = (ImageView)findViewById(R.id.imageView1);     
myimage.setImageDrawable(getResources().getDrawable(R.drawable.img01));
Thread.sleep(500);
myimage.setImageDrawable(null);
Thread.sleep(700);
Button button2 = (Button) (findViewById(R.id.button2));
button2.setEnabled(true);
...
ImageView myimage = (ImageView)findViewById(R.id.imageView1);
myimage.setImageDrawable(getResources().getDrawable(R.drawable.img01));
myImage.postDelayed(new Runnable() {
    public void run() {
        myimage.setImageDrawable(null);
        myImage.postDelayed(new Runnable() {
            public void run() {
                Button button2 = (Button) (findViewById(R.id.button2));
                button2.setEnabled(true);
            }
        }, 700);
    }
}, 500);