Voorbeeld-programma's

Slides:



Advertisements
Similar presentations
You’ll Never Walk Alone ! Gerry and the Pacemakers
Advertisements

HM-ES-th1 Les 7 Hardware/Software Codesign with SystemC.
Console applicatie static void Main ( ) class Hallo { } { } Console. WriteLine("Hallo " + naam + "!" ); statische methodestatische methoden Console. WriteLine("Wat.
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag Dallas one-wire interface Opgave:
Deltion College Engels B1 Gesprekken voeren [Edu/003] thema: What about August? can-do : kan deelnemen aan routinematige discussies over praktische zaken.
Korte vragen (Question tags) Jij bent wel cool, toch? Zij is niet zo slim, he? Je bent niet boos, of wel? In het Engels doen we dit heel anders: Herhaal.
All Right! 1thv Unit 4 grammar 4.2. Hoe zet je in het Engels een woord in het meervoud?
Go with God Carolyn Arends. Farther than lands you have ever imagined Verder dan landen die jij ooit kunt bedenken Deeper than even the oceans of blue.
Probleem P 1 is reduceerbaar tot P 2 als  afbeelding  :P 1  P 2 zo dat: I yes-instantie van P 1   (I) yes-instantie van P 2 als ook:  polytime-algoritme,
When you walk through a storm through a storm hold your head up high Als je loopt door een storm hou je hoofd omhoog.
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag functie definitions;.h files;
Onderwerpen voor vandaag
Je gebruikt will of going to als je het over de toekomst hebt. I will phone you tonight. Next week we will know the results.
STEEL AT WORK. MET DANK AAN STEEL AT WORK.
Kennismaken met samenwerkings-tools Aanmaken van groepssets MARK EN SLADJANA MAATSCHAPPELIJKE ZORG DINSDAG 14 APRIL 2015 BLACKBOARD-TRAINING.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Android Form Elements. Views Provide common UI functionality Form elements: text area, button, radio button, checkbox, dropdown list, etc. Date and time.
Array nDeclaratie nCreatie nOpvragen nWijzigen nLengte String [ ] a; a = new String[10]; ……a[5]…… a[5] = ……; …a.length… …is eigenlijk overbodig! ArrayList.
Wordpress Hoe doe je dat bij DSE Bloggen met. Log in op de homepage, klik in mijn account op Wordpress installeren.
Het leven als schipper is niet altijd Roze geur & manen schijn.
2D Graphics: Part 2.
Android Tutorial Team 3 Jerry Yu Mayank Mandava Mu Du Will Wangles.
1 Scroll Bars Providing Scrollbars. 2 Objectives You will be able to: Use Windows Graphics to display tabular information on a Windows form. Add graphics.
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.
Import import android.graphics.Bitmap; import android.widget.ImageView;
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Custom Widget 1 UNIT 26 로봇 SW 콘텐츠 교육원 조용수. 캔버스 public void drawColor(int color) 2 public class ControllerView extends View { public ControllerView(Context.
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.
WxHaskell Daan Leijen. Ok…. Dat lijkt me een goed plan. Denk je dat je zo iets dinsdag af kunt hebben en presenteren? Doaitse On donderdag, september.
Android Threads. Threads Android will show an “ANR” error if a View does not return from handling an event within 5 seconds Or, if some code running in.
Android Application Lifecycle and Menus
(2.2) Hallo één klasse...met één methode...met acht opdrachten accolades begrenzen klasse en methode using Android.OS; using Android.App; using Android.Widget;
로봇을 조종하자 1/5 UNIT 14 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 터치 이벤트를 처리할 수 있다. 2.
Custom Widget 2 UNIT 27 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Custom Widget –Canvas 를 이용하여 Custom Widget 을 만든다. 2.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
1 Working with Controls at Run Time. 2 Objectives You will be able to Add controls to a Windows form at run time. Modify controls at run time.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
in de cloud werken voor allerlei bestanden overal up- en downloaden.
Migratie in de moderne tijd ( ) Hoofdstuk 5.
Mijn gemeente Soorten bebouwing Gebruikte symbolen Ga naar mijn volgende dia Ga naar mijn voorgaande dia Ik wil nog even mijn informatie raadplegen.
Lunch time Iets bestellen in London. Be polite! Begin je zin met “I’d like” Eindig altijd met “please” Bijvoorbeeld: “I’d like a hamburger, please”
Lecture 3: Animation & Graphics Topics: Animation, Graphics, Drawing Date: Feb 2, 2016.
Primes Andere joker – andere achterzijde Jan Pelssers.
Lecture 3: Animation & Graphics
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
Gameprogrammeren: Klassen en objecten in Painter
GUI Programming Fundamentals
滑動版面 建國科技大學 資管系 饒瑞佶 2013/7 V1.
Lecture 3: Animation & Graphics
Android – Event Handling
string versus array Klasse Type met speciale syntax Indexer -notatie
(H9.1) CirkelKlikker ARRAY int x, y; [ ] int n=0;
Programmeren van visuele gebruikersomgevingen
Gameprogrammeren: Edit states
Android Introduction Camera.
Gameprogrammeren: Menu’s in Penguin Pairs
Android Programming Lecture 6
MultiUni Trần Vũ Tất Bình
null, true, and false are also reserved.
Many thanks to Jun Bum Lim for his help with this tutorial.
בניית מחלקות.
Gameprogrammeren: Interactie in Penguin Pairs
動態版面 建國科技大學 資管系 饒瑞佶 2017/7.
Gameprogrammeren: Game states
Adding Components to Activity
Lasalle-App Tecnología Móvil.
CIS 470 Mobile App Development
Poker2.jpg Poker14.jpg int num1, num2;
Presentation transcript:

Voorbeeld-programma's Activity met een TextView Meerdere views stapelen Reageren op een Button Alles tegelijk Eigen tekening

(2.2) Hallo één klasse ...met één methode toekennings- opdrachten using Android.OS; using Android.App; using Android.Widget; using Android.Graphics; [ActivityAttribute(Label = "Hello", MainLauncher = true)] public class HalloApp : Activity { protected override void OnCreate(Bundle b) { base.OnCreate(b); TextView scherm; scherm = new TextView(this); scherm.Text = "Hallo!"; scherm.TextSize = 80; scherm.SetBackgroundColor(Color.Yellow); scherm.SetTextColor(Color.DarkBlue); this.SetContentView(scherm); } één klasse ...met één methode toekennings- opdrachten ...met acht opdrachten accolades begrenzen klasse en methode methode- aanroepen

(2.6) Klok AnalogClock wijzerklok; wijzerklok = new AnalogClock(this); wijzerklok.SetBackgroundColor(Color.Yellow); TextClock tekstklok; tekstklok = new TextClock(this); tekstklok.Format24Hour = "EEE HH:mm:ss"; tekstklok.TextSize = 50; TextView scherm; scherm = new TextView(this); scherm.Text = "Hallo!"; scherm.TextSize = 80; scherm.SetBackgroundColor(Color.Yellow); scherm.SetTextColor(Color.DarkBlue); this.SetContentView( scherm );

(2.6) Klok AnalogClock wijzerklok; wijzerklok = new AnalogClock(this); wijzerklok.SetBackgroundColor(Color.Yellow); TextClock tekstklok; tekstklok = new TextClock(this); tekstklok.Format24Hour = "EEE HH:mm:ss"; tekstklok.TextSize = 50; LinearLayout stapel; stapel = new LinearLayout(this); stapel.Orientation = Orientation.Vertical; stapel.AddView(wijzerklok); stapel.AddView(tekstklok); this.SetContentView( scherm ); stapel

(3.1) Teller Button public class KlikkerApp : Activity { int teller; Button knop; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; SetContentView(knop); } teller = 0; Button knop.Click += klik; public void klik(object o, EventArgs ea) { teller = teller + 1; knop.Text = teller.ToString() + " keer geklikt"; } }

Event-property van Button public class KlikkerApp : Activity { (3.1) Teller int teller; Button knop; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; SetContentView(knop); } teller = 0; properties van Button Event-property van Button knop.Click += klik; …krijgt als waarde een… public void klik(object o, EventArgs ea) { Event-handler teller = teller + 1; knop.Text = teller.ToString() + " keer geklikt"; } }

(3.1) Teller Button public class KlikkerApp : Activity { Button knop; int teller; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; knop.Click += klik; SetContentView(knop); } teller = 0; Button public void klik(object o, EventArgs ea) { teller = teller + 1; knop.Text = teller.ToString() + " keer geklikt"; } }

(3.2) Mixer SeekBar SeekBar SeekBar Button public class MixerApp : Activity { (3.2) Mixer Button knop; SeekBar rood, groen, blauw; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Text = "Klik hier!"; knop.TextSize = 40; knop.Click += kies; SetContentView(knop); } rood = new SeekBar(this); rood.SetBackgroundColor(Color.Red); rood.ProgressChanged += schuif; groen= new SeekBar(this); groen.SetBackgroundColor(Color.Green); groen.ProgressChanged += schuif; blauw= new SeekBar(this); blauw.SetBackgroundColor(Color.Blue); blauw.ProgressChanged += schuif; SeekBar SeekBar SeekBar Button LinearLayout lay = …… SetContentView(lay); public void kies(object o, EventArgs ea) { } public void schuif(object o, EventArgs ea) { } }

(3.2) Mixer SeekBar SeekBar SeekBar Button SeekBar rood, groen, blauw; Button knop; (3.2) Mixer public void schuif(object o, EventArgs ea) { int r, g, b; r = rood.Progress; g = groen.Progress; b = blauw.Progress; SeekBar SeekBar SeekBar knop.Text = "r:" + r + "g:" + g + "b:" + b; knop.SetBackgroundColor ( new Color(r, g, b) ); Button } public void kies(object o, EventArgs ea) { Random gen; gen = new Random(256); rood.Progress = gen.Next(); groen .Progress = gen.Next(); blauw .Progress = gen.Next(); }

(4.1) Maak je eigen View bestaat nog niet… protected override void OnCreate(Bundle b) { base.OnCreate(b); TextView t; t = new TextView(this); this.SetContentView(t); AnalogClock a; a = new AnalogClock(this); this.SetContentView(a); MondiaanView m; m = new MondriaanView(this); this.SetContentView(m); }

(4.1) Maak je eigen View public class MondriaanView : View { public MondriaanView(Context ct) { } : base(ct) base.View(ct); this.SetBackgroundColor(Color.White); protected override void OnDraw(Canvas cv) { base.OnDraw(cv); cv . DrawLine(…); cv . DrawRect(…); cv . DrawCircle(….); } }

(4.6) Maak je eigen Methodes public class MondriaanView : View { protected override void OnDraw(Canvas cv) { base.OnDraw(cv); cv . DrawLine(…); cv . DrawRect(…); cv . DrawCircle(….); this . TekenHuis(cv, …); } }

(4.6) Maak je eigen Methodes private void tekenHuis (Canvas c, … ) { Paint verf = new Paint(); int x, int y, int br) (tx,ty) int tx = x+br/2; int ty = y–br–br/2; c.DrawRect ( … , verf); c.DrawLine ( … , verf); c.DrawLine ( … , verf); x, y-br, x+br, y x, y-br, tx, ty tx, ty, x+br, y-br } (x,y) br protected override void OnDraw(Canvas c) { this . tekenHuis (c, …); this . tekenHuis (c, …); this . tekenHuis (c, …); 20, 100, 40); 70, 100, 40); 120, 100, 60); }

(3.1) Teller class MijnAct : Activity { Button knop; protected override void OnCreate(Bundle b) { base.OnCreate(b); knop = new Button(this); knop.Click += klik; this.SetContentView(knop); } public void klik(object o, EventArgs ea) { } knop.Text = "1x geklikt"; }

(6.1) Touch class MijnAct : Activity { MijnView scherm; protected override void OnCreate(Bundle b) { base.OnCreate(b); scherm = new MijnView(this); knop.Click += klik; this.SetContentView(scherm); } public void klik(object o, EventArgs ea) { } knop.Text = "1x geklikt"; }

(6.1) Touch class MijnAct : Activity { MijnView scherm; protected override void OnCreate(Bundle b) { base.OnCreate(b); scherm = new MijnView(this); scherm.Click += klik; this.SetContentView(scherm); } } class MijnView : View { public MijnView(Context c) : base(c) { } protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(...); }

(6.1) Touch class MijnAct : Activity { MijnView scherm; protected override void OnCreate(Bundle b) { base.OnCreate(b); scherm = new MijnView(this); scherm.Touch += raakAan; this.SetContentView(scherm); } public void raakAan(object o, EventArgs ea) { } } class MijnView : View { public MijnView(Context c) : base(c) { } protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(...); }

(6.1) Touch class MijnAct : Activity { MijnView scherm; protected override void OnCreate(Bundle b) { base.OnCreate(b); scherm = new MijnView(this); scherm.Touch += raakAan; this.SetContentView(scherm); } public void raakAan(object o, EventArgs ea) { } } class MijnView : View { public MijnView(Context c) : base(c) { } this.Touch += raakAan; protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(...); public void raakAan(object o, EventArgs ea) { } }

(6.1) Touch class MijnAct : Activity { MijnView scherm; protected override void OnCreate(Bundle b) { base.OnCreate(b); scherm = new MijnView(this); this.SetContentView(scherm); } } class MijnView : View { public MijnView(Context c) : base(c) { } this.Touch += raakAan; protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(...); public void raakAan(object o, EventArgs ea) { } }

(6.1) Touch } class MijnView : View { float x, y; public MijnView(Context c) : base(c) { this.Touch += raakAan; } protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(x, y, 50, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); }

(6.1) Touch } class MijnView : View { PointF p; float x, y; public MijnView(Context c) : base(c) { this.Touch += raakAan; } protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(x, y, 50, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } x = tea.Event.GetX(); y = tea.Event.GetY(); this.Invalidate(); }

(6.1) Touch } class MijnView : View { PointF p; public MijnView(Context c) : base(c) { this.Touch += raakAan; } protected override void OnDraw(Canvas c) { base.OnDraw(c); } c.DrawCircle(p.X, p.Y, 50, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } float x, y; x = tea.Event.GetX(); y = tea.Event.GetY(); p = new PointF(x, y); this.Invalidate(); }

(6.1) Touch } class MijnView : View { PointF p; public MijnView(Context c) : base(c) { this.Touch += raakAan; } protected override void OnDraw(Canvas c) { base.OnDraw(c); } if (p != null) c.DrawCircle(p.X, p.Y, 50, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } float x, y; x = tea.Event.GetX(); y = tea.Event.GetY(); p = new PointF(x, y); this.Invalidate(); }

if-opdracht if (temperatuur<0) uitvoer.Text = "Het vriest!”; else uitvoer.Text = "Het dooit."; opdracht wordt alleen uitgevoerd als voorwaarde geldt opdracht wordt alleen uitgevoerd als voorwaarde niet geldt

Vergelijk-operatoren < kleiner dan <= kleiner dan of gelijk aan > groter dan >= groter dan of gelijk aan == gelijk aan != ongelijk aan x=5 x wordt 5 ! x==5 is x gelijk aan 5 ?

Syntax van opdrachten opdracht naam naam ( expressie ) ; . , expressie klasse naam methode naam ( expressie ) ; . , object expressie property naam += variabele = expressie ; return expressie ; if ) ( expressie opdracht else opdracht blok

(6.1) Touch } class MijnView : View { PointF p; public MijnView(Context c) : base(c) { this.Touch += raakAan; } protected override void OnDraw(Canvas c) { base.OnDraw(c); } if (p != null) c.DrawCircle(p.X, p.Y, 50, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } float x, y; x = tea.Event.GetX(); y = tea.Event.GetY(); p = new PointF(x, y); this.Invalidate(); }

(6.1) Bitmap } class MijnView : View { PointF p; Bitmap b; public MijnView(Context c) : base(c) { this.Touch += raakAan; } b = BitmapFactory.DecodeResource(...Icon...); protected override void OnDraw(Canvas c) { base.OnDraw(c); } if (p != null) c.DrawBitmap(b, p.X, p.Y, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } float x, y; x = tea.Event.GetX(); y = tea.Event.GetY(); p = new PointF(x, y); this.Invalidate(); }

Punten- klikker met bitmap } class MijnView : View { Bitmap b; List<PointF> alles = new List<PointF>( ) ; public MijnView(Context c) : base(c) { this.Touch += raakAan; } met bitmap b = BitmapFactory.DecodeResource(...Icon...); protected override void OnDraw(Canvas c) { base.OnDraw(c); } foreach( PointF p in alles) c.DrawBitmap(b, p.X, p.Y, new Paint()); public void raakAan(object o, TouchEventArgs tea) { } float x, y; PointF p; x = tea.Event.GetX(); y = tea.Event.GetY(); p = new PointF(x, y); alles.Add(p); this.Invalidate(); }

Syntax van opdrachten opdracht naam naam ( expressie ) ; . , expressie klasse naam methode naam ( expressie ) ; . , object expressie property naam += variabele = expressie ; return expressie ; if ) ( expressie opdracht else opdracht blok foreach ( type naam in expr ) opdracht