gpt4 book ai didi

android - 寻找一个快速简单的等待命令

转载 作者:搜寻专家 更新时间:2023-11-01 07:38:32 24 4
gpt4 key购买 nike

在一个快速等待命令之后,我的应用程序将停止,比如 10 毫秒,这样它看起来就像是动画的东西(在我的例子中是一个球)。

    public class PiranhaDrop extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

FrameLayout main = (FrameLayout) findViewById(R.id.main_view);
main.addView(new Drawing(this,0,0,0));
int MyLoop=0;
while(MyLoop<100)
{
main.addView(new Drawing(this,MyLoop,10,10));
synchronized(this){wait(10);}
//try{Thread.sleep(WaitTime);} catch (InterruptedException e){}
MyLoop=MyLoop+1;
main.setOnTouchListener(new View.OnTouchListener()
{
public boolean onTouch(View v, MotionEvent e)
{
float x = e.getX();
float y = e.getY();
FrameLayout flView = (FrameLayout) v;
flView.addView(new Drawing(getParent(),x,y,25));
return false;
}
});
}
}

如您所见,就在循环开始后,我尝试了一些方法(WaitTime 指的是我去掉的 long,它没有用)- 两者都没有用。

谢谢。

最佳答案

无需手动执行此操作。使用 frame animation (带有一系列位图)或更好的 tween animation (移动/调整现有 View 的大小)。

关于android - 寻找一个快速简单的等待命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7195655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com