0

这是我的代码;

ib=(ImageButton)findViewById(R.id.imagebutton1);
ib1.setImageResource(i);
Toast.makeText(MainActivity.this,"Fail",1000).show();
Thread.sleep(10000);
ib1.setImageResource(R.drawable.bck_image1);

请尽快给出一些建议。

4

3 回答 3

2

更改按钮单击时图像按钮可见性的代码

btn.setOnClickListener(new onClickListener()
{
    //For changing visibility
    ib.setVisibility(View.VISIBLE);
    ib1.setVisibility(View.GONE); //or View.INVISIBLE - as per youur requirement.
    //For changing image resources
    ib.setImageResource(R.drawable.apple);
});
于 2012-12-28T06:18:18.157 回答
2

试试下面的片段可能会有所帮助

ib1.setImageResource(i);
Toast.makeText(MainActivity.this,"Fail",1000).show();
android.os.Handler mHandler = new android.os.Handler();
android.os.Handler mHandler = new android.os.Handler();
    mHandler.postDelayed(new Runnable()
    {

        public void run()
        {
            ib1.setImageResource(R.drawable.bck_image1);
    }},1000);
于 2012-12-28T06:22:55.187 回答
0

使用setVisibility(int)功能。您可以使用

用于隐藏

image.setVisibility(VIEW.INVISIBLE)

并使其可见使用

image.setVisibility(INVISIBLE)

检查以下链接了解更多详情 http://developer.android.com/reference/android/view/View.html#setVisibility(int )

于 2012-12-28T06:21:53.853 回答