Search

'Andoid 매트로돔'에 해당되는 글 1건

  1. 2013.08.19 Andoid 매트로돔

Andoid 매트로돔

Programming/Android 2013. 8. 19. 17:21 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tistory.tansanc.Test130805;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

public class MainActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		mDdok = mPool.load(this, R.raw.ddok, 1);
		MyView mv = new MyView(this, mHandler);
		setContentView(mv);
	}

	Handler mHandler = new Handler() {
		public void handleMessage(Message msg) {
			mPool.play(mDdok, 1, 1, 0, 0, 1);
		}
	};

	SoundPool mPool;
	int mDdok;

	class MyView extends View {
		Context context;
		Handler mDdokHandler;

		public MyView(Context context, Handler mDdokHandler) {
			super(context);
			this.context = context;
			this.mDdokHandler = mDdokHandler;
			mHandler.sendEmptyMessage(0);
		}

		float degree = 0;
		float inc = 1;

		@Override
		protected void onDraw(Canvas canvas) {
			// TODO Auto-generated method stub

			Paint Pnt = new Paint();
			Pnt.setAntiAlias(true);
			Pnt.setColor(Color.RED);
			Pnt.setStrokeWidth(20);

			canvas.translate(canvas.getWidth() / 2, canvas.getHeight() / 4 * 3);
			if (degree > 45) {
				inc = -1;
				mDdokHandler.sendEmptyMessage(0);
			} else if (degree < -45) {
				inc = 1;
				mDdokHandler.sendEmptyMessage(0);
			}
			canvas.rotate(degree);
			canvas.drawLine(0, 0, 0, -canvas.getHeight() / 2, Pnt);
			super.onDraw(canvas);
		}

		Handler mHandler = new Handler() {
			public void handleMessage(Message msg) {
				degree = degree + inc;
				invalidate();
				mHandler.sendEmptyMessageDelayed(0, 50);
			}
		};
	}
}

'Programming > Android' 카테고리의 다른 글

Android 채팅 소스 01  (0) 2013.08.20
Android Download html  (0) 2013.08.20
Android 시계  (0) 2013.08.19
Andoid 알람 기능으로 라디오 mms 주소로 듣기  (0) 2013.08.16
Android 라디오 mms 주소로 듣기  (1) 2013.08.16