ホームに戻る
アニメ
package org.example.test;
import android.app.*;
import android.content.*;
import android.graphics.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class Anime extends Activity implements Runnable
{
private int width;
private int height;
private float count = 0.0f;
private Handler hdl;
private SampleView sv;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
Display disp = wm.getDefaultDisplay();
width = disp.getWidth();
height = disp.getHeight();
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
setContentView(ll);
hdl = new Handler();
hdl.postDelayed(this, 10);
sv = new SampleView(this);
ll.addView(sv);
}
public void run()
{
count += 0.1f;
sv.invalidate();
hdl.postDelayed(this, 10);
}
public void onDestroy()
{
super.onDestroy();
hdl.removeCallbacks(this);
}
class SampleView extends View
{
private float x, y;
public SampleView(Context cn)
{
super(cn);
x = width / 2;
y = height / 2;
}
protected void onDraw(Canvas cv)
{
super.onDraw(cv);
Paint p = new Paint();
p.setColor(Color.argb(255,0,255,0));
cv.drawCircle(x + (int)(Math.sin(count) * (width / 3)), y, 10, p);
}
}
}