私のコードのようですが、これにはスレッドの減価償却方法のエラーがあります
class x implements Threads{
public void run()
{
someButton.layout(10,k,40,40);
k+=10;
}}
私のコードのようですが、これにはスレッドの減価償却方法のエラーがあります
class x implements Threads{
public void run()
{
someButton.layout(10,k,40,40);
k+=10;
}}
Android の組み込みアニメーションを試してみませんか
あなたがすべて望んでいたのは、オブジェクトの使用を移動することですTranslateAnimation
入れることを忘れないでくださいobject.setFillAfter(true);
そうしないと、オブジェクトは再び元の場所に戻ってきます。
以下のスニペットが役立ちます。
package org.sample;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
public class AnimationActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);
final TextView tv = new TextView(this);
tv.setText("Animation");
final TranslateAnimation moveLefttoRight = new TranslateAnimation(0,
200, 0, 0);
moveLefttoRight.setDuration(1000);
moveLefttoRight.setFillAfter(true);
Button button = new Button(this);
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
button.setText("PressMe");
button.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
tv.startAnimation(moveLefttoRight);
}
});
ll.addView(tv);
ll.addView(button);
setContentView(ll);
}
}