当点击其他按钮时,如何在一个按钮上闪烁效果......?
我有一些按钮,一个是主按钮,其他按钮是子按钮,当我触摸子按钮时,我希望主按钮有闪烁效果。
我在所有子按钮上使用了 onTouchListener,在这些侦听器中,我正在调用一个用于闪烁主按钮的方法。
方法。
public void refreshMainButton() {
Bitmap b1 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_one));
Bitmap b2 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_two));
Bitmap b3 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_three));
Bitmap b = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabmain_two));
BitmapDrawable d1 = new BitmapDrawable(b1);
outerImageViews[1].setBackgroundDrawable(d1);
BitmapDrawable d2 = new BitmapDrawable(b2);
outerImageViews[1].setBackgroundDrawable(d2);
BitmapDrawable d3 = new BitmapDrawable(b3);
outerImageViews[1].setBackgroundDrawable(d3);
try {
wait(1000);
} catch (Exception e) {
}
BitmapDrawable d4 = new BitmapDrawable(b);
outerImageViews[1].setBackgroundDrawable(d4);
}
这对主按钮没有影响。
如果有人有任何想法,请帮助我。
提前致谢...!
I have some buttons one is main, others are child, I want blinking effect on main button when I touch child buttons.
I have used onTouchListener on all child buttons, in those listeners, I am calling a method which i used to blink the main button.
method.
public void refreshMainButton() {
Bitmap b1 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_one));
Bitmap b2 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_two));
Bitmap b3 = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabouterover_three));
Bitmap b = Bitmap.createBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.tabmain_two));
BitmapDrawable d1 = new BitmapDrawable(b1);
outerImageViews[1].setBackgroundDrawable(d1);
BitmapDrawable d2 = new BitmapDrawable(b2);
outerImageViews[1].setBackgroundDrawable(d2);
BitmapDrawable d3 = new BitmapDrawable(b3);
outerImageViews[1].setBackgroundDrawable(d3);
try {
wait(1000);
} catch (Exception e) {
}
BitmapDrawable d4 = new BitmapDrawable(b);
outerImageViews[1].setBackgroundDrawable(d4);
}
This is showing no effect on main button.
If any one has any idea, please help me.
Thanks in advance...!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 动画 来存档此效果。
Android 对 Activity 有非常严格的限制 - 如果 Activity 在一定时间内(我猜是 5 秒)没有响应,应用程序会显示一个对话框来结束它。进入这个陷阱时,您可能会使用 wait 结构来运行。
现在您可能会考虑将其放入线程中。但这是行不通的,因为只能从 Activity 内部操作 UI。
因此,只需创建一个动画并启动它即可。 Android 将执行重置:)
我希望我能帮忙。
I would recommend to use animations to archive this effect.
Android has very harsh limits in the Activity - if the Activity does not respond within a certain time (I guess it was 5 seconds) the application shows a dialog to end it. Into this trap you will run (perhaps) with the wait construct.
Now you might think of laying this out into a thread. But this won't work, because the UI can only be manipulated from inside the activity.
So just create an animation and start it. Android will do the reset :)
I hope I could help.