package com.example.androidtest0222;
import android.R.bool;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.View;
import android.widget.RelativeLayout;
public class MainActivity extends Activity {
RelativeLayout backLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
class MyView extends View {
public MyView(Context context) {
super(context);
}
public MyView(Context context, AttributeSet attri) {
super(context, attri);
mHandler.sendEmptyMessageDelayed(0, 500);
}
boolean flag = false;
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
if(flag)
{
canvas.drawColor(Color.YELLOW);
flag = !flag;
}
else
{
canvas.drawColor(Color.GREEN);
flag = !flag;
}
super.onDraw(canvas);
}
Handler mHandler = new Handler()
{
public void handleMessage(android.os.Message msg) {
invalidate();
mHandler.sendEmptyMessageDelayed(0, 500);
};
};
}
'Programming > Android' 카테고리의 다른 글
Android 지도 테스트 (0) | 2014.03.01 |
---|---|
Android 2014-03-01 GoogleMap V2 띄우기 (0) | 2014.03.01 |
Android GoogleMap API V2 (0) | 2014.01.19 |
viewpagertest (0) | 2014.01.14 |
Android FrameLayout 예제 (0) | 2014.01.12 |