로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.

Slides:



Advertisements
Similar presentations
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Advertisements

Touch & Gestures.  MotionEvents  Touch Handling  Gestures.
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
로봇 모니터링 2/2 UNIT 21 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Broadcasting Service 2.
1 Mobile Computing Advanced Touching Copyright 2014 by Janson Industries Assg Part1Assg Part1 AssgPart2AssgPart2.
Linear Layout, Screen Support, and Events. Linear Layout Supports 2 orientations: 1.Horizontal 2.Vertical I often get confused with how each orientation.
Animation.
로봇 전화번호부 4/4 UNIT 12 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 뷰 홀더 패턴을 사용할 수 있다. 토스트를 사용할 수 있다. 클릭 이벤트를 처리할 수 있다. 2.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
전광판 만들기 UNIT 04 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Layout XML 이란 ? 기본 XML 속성 Text View 2.
Android - Broadcast Receivers
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
Import import android.graphics.Bitmap; import android.widget.ImageView;
로봇 모션 편집기 4/4 UNIT 25 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 에디트 텍스트를 사용할 수 있다. 아이템을 삭제할 수 있다. 아이템을 편집할 수 있다. 2.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Resources and RelativeLayouts. Resources Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type.
Activity 생명주기 UNIT 13 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Logcat 액티비티 생명주기를 설명할 수 있다. 현재 상태를 저장할 수 있다. 2.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
Mobile Programming Lecture 12 HierarchyViewer, Linkify, Gestures, and Version Control.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android View Stuff. TextViews Display text Display images???
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Android and s Ken Nguyen Clayton state University 2012.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
CHAP 14. 프로세스와 스레드. © 2012 생능출판사 All rights reserved 다중 스레딩 하나의 애플리케이션이 동시에 여러 가지 작업을 하 는 것 이들 작업은 스레드 (thread) 라고 불린다.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
CHAP 6. 이벤트 처리. © 2012 생능출판사 All rights reserved 폴링과 이벤트 구동 방식.
Google map v2.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
TUTORIAL ON MULTITOUCH AND SWIPE GESTURES
Android Introduction Hello World
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
GUI Programming Fundamentals
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
Linear Layout, Screen Support, and Events
Android – Event Handling
CS499 – Mobile Application Development
Android Widgets 1 7 August 2018
ITEC535 – Mobile Programming
Android – Read/Write to External Storage
Mobile Computing With Android ACST 4550 Bitmaps, Fonts and Gestures
CIS 470 Mobile App Development
Android Programming Lecture 6
CIS 470 Mobile App Development
null, true, and false are also reserved.
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
Chapter 7: Touches and Swipes
動態版面 建國科技大學 資管系 饒瑞佶 2017/7.
滑動 建國科技大學 資管系 饒瑞佶 2013/4 V1 2015/5 V2.
滑動 建國科技大學 資管系 饒瑞佶.
CIS 470 Mobile App Development
Mobile Programming Gestures in Android.
Adding Components to Activity
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
Android Play YouTuBe 建國科技大學 資管系 饒瑞佶 2017/10 V1.
Lasalle-App Tecnología Móvil.
CIS 470 Mobile App Development
Android Sensor Programming
Android Sensor Programming
Presentation transcript:

로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수

학습 목표 터치 이벤트를 처리할 수 있다. 2

미션 3

터치 이벤트 Activity –public boolean onTouchEvent (MotionEvent event) View –public boolean onTouchEvent (MotionEvent event) –public void setOnTouchListener(View.OnTouchListener l) OnTouchListener –public abstract boolean onTouch (View v, MotionEvent event) 4

터치 이벤트 public final int getAction () –ACTION_UP –ACTION_DOWN –ACTION_MOVE –ACTION_HOVER_ENTER –ACTION_HOVER_EXIT –ACTION_HOVER_MOVE 5 TouchEvent Object InputEvent –ACTION_CANCEL –ACTION_SCROLL –ACTION_OUTSIDE –…

터치 이벤트 - 액티비티 6 <LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="100dp" android:background="#ffff0000" android:gravity="center" />

터치 이벤트 - 액티비티 7 public class MainActivity extends Activity { private TextView protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView)findViewById(R.id.text); public boolean onTouchEvent(MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: mTextView.setText(R.string.down); return true; case MotionEvent.ACTION_UP: mTextView.setText(R.string.up); return true; } return super.onTouchEvent(event); }

터치 이벤트 - 리스너 8 public class MainActivity extends Activity { private TextView protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView)findViewById(R.id.text); mTextView.setOnTouchListener(new OnTouchListener() public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: mTextView.setText(R.string.down2); return true; case MotionEvent.ACTION_UP: mTextView.setText(R.string.up2); return true; } return false; } }); }

터치 이벤트 – 로봇 움직이기 9 public class MainActivity extends RobotActivity { private TextView mTextView; private Device mLeftWheelDevice; private Device mRightWheelDevice; private boolean protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView)findViewById(R.id.text); mTextView.setOnTouchListener(new OnTouchListener() public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: mLeftWheelDevice.write(0); mRightWheelDevice.write(0); return true; } return false; } }); }

터치 이벤트 – 로봇 움직이기 public void onInitialized(Robot robot) { super.onInitialized(robot); mLeftWheelDevice = robot.findDeviceById(Albert.EFFECTOR_LEFT_WHEEL); mRightWheelDevice = robot.findDeviceById(Albert.EFFECTOR_RIGHT_WHEEL); public boolean onTouchEvent(MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: mLeft = !mLeft; if(mLeft) { mLeftWheelDevice.write(0); mRightWheelDevice.write(30); } else { mLeftWheelDevice.write(30); mRightWheelDevice.write(0); } return true; } return super.onTouchEvent(event); }

로봇 조종기 만들기 11

터치 이벤트 - 리스너 12 View.OnTouchListener touchListener = new OnTouchListener() public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int action = event.getAction(); switch(action) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: if(v.equals(tvLeft)) { LeftWheel.write(20); } else if(v.equals(tvRight)) { RightWheel.write(20); } break; case MotionEvent.ACTION_UP: break; } return true; } };

터치 이벤트 – 좌표 저장 13 public class MainActivity extends RobotActivity { Device LeftWheel; Device RightWheel; TextView tvLeft; TextView tvRight; PointF startP; PointF protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startP = new PointF(); diffP = new PointF();

터치 이벤트 – 좌표 저장 14 View.OnTouchListener touchListener = new OnTouchListener() public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int action = event.getAction(); switch(action) { case MotionEvent.ACTION_DOWN: startP.x = event.getX(); startP.y = event.getY(); break;

터치 이벤트 – 좌표 저장 15 case MotionEvent.ACTION_MOVE: diffP.x = event.getX(); diffP.y = event.getY(); int speed = (int)(startP.y - diffP.y)/10; if(v.equals(tvLeft)) { LeftWheel.write(speed); } else if(v.equals(tvRight)) { RightWheel.write(speed); } break; case MotionEvent.ACTION_UP: if(v.equals(tvLeft)) { LeftWheel.write(0); } else if(v.equals(tvRight)) { RightWheel.write(0); } break;