如何实现onClick的延迟?

use*_*813 3 android

我在桌面行上有一个onclick,我想在显示下一个屏幕之前将行的颜色改变一秒钟.这可能吗?这是我目前的代码.

public void onClick(View v) {
String sdet_id;
int det_id;
v.setBackgroundColor(Color.GRAY);
det_id = v.getId();
sdet_id = String.valueOf(det_id);
Intent i = new Intent();
i.setClassName("demo.learningdroid.com", "demo.learningdroid.com.details");
i.putExtra("Det_id", sdet_id);
startActivity(i);
v.setBackgroundColor(Color.TRANSPARENT);
// TODO Auto-generated method stub
}
});
Run Code Online (Sandbox Code Playgroud)

小智 5

使用 postDelayed()

    v.postDelayed(new Runnable() {
        @Override
        public void run() {
            //Your code that opens another activity
        }
    }, 1000L);
Run Code Online (Sandbox Code Playgroud)