게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
아까 밑에 그림 이동한다던 녀석입니다.
게시물ID : programmer_3899짧은주소 복사하기
작성자 : 아버지레드불
추천 : 0
조회수 : 668회
댓글수 : 6개
등록시간 : 2014/06/10 16:18:53
package com.example.termproject;

import com.example.termproject.R.drawable;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.Menu;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Gallery;
import android.widget.GridLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableLayout.LayoutParams;

public class MainActivity extends Activity {
    private RelativeLayout mRelativeLayout;
    private int i;
    private int x = 0;
    private int y = 0;
    testThread test = new testThread();
    ImageView wh1 ;
    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);    // 타이틀을 없애는 것.
        // ImageView 를 추가하기 위한 RelativeLayout 생성
        mRelativeLayout = new RelativeLayout(this);

        mRelativeLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.board));
        // ImageView 객체 생성

        wh1 = new ImageView( this ) ;
        wh1.setImageResource(R.drawable.wh);
//        wh1.setX(x);
//        wh1.setY(y);
//        wh1.setLayoutParams(new Gallery.LayoutParams(40,40));

        mRelativeLayout.addView(wh1);
        setContentView(mRelativeLayout);
        test.start();
    }

    public class testHandler extends Handler{

        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            wh1.scrollTo(--x, --y);
            mRelativeLayout.invalidate();
        }
        
    }
    
    public class testThread extends Thread{
        private testHandler handler = new testHandler();
        public void run(){
            for( int i=0; i<100; i++ ) {
                try{
                    sleep(50);
                    handler.sendEmptyMessage(0);
                } catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        }
    }
}

아까 밑에서 보니 엄청난 실수를 저질렀더군요..;;;

그래서 이번엔 Thread를 이용해서 바둑알이 이동하도록 했는데,

이미지가 이동하는게 아니라, 어느 틀 안에서만 이동하더군요;;;;

왜 그런거죠??
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호