Slide 1

Slide 1 text

"OESPJEΞϓϦΛ࡞Δ ,.$OPOZMFOF ը૾ؔ܎ɾ+BWB͔ΒͷϨΠΞ΢τɾઃఆ஋

Slide 2

Slide 2 text

ࣗݾ঺հ w OPOZMFOF ͷʹΕΜ w ,.$ճ w ΧʔϏΟͰ͢ w ϙέϞϯϐΫϩεপ w SPPU

Slide 3

Slide 3 text

ࣗݾ঺հ w OPOZMFOF ͷʹΕΜ w εϚϗΞϓϦͱ͔ w 5XJUUFS(JU)VCFUD w IUUQOPOZMFOFIBUFOBCMPHKQ

Slide 4

Slide 4 text

͜Μ͹Μ͸

Slide 5

Slide 5 text

ࠓ೔΍Δ͜ͱ ը૾ؔ܎ *NBHF7JFX ϨΠΞ΢τGSPN+BWB ઃఆ஋อଘ

Slide 6

Slide 6 text

ը૾ؔ܎

Slide 7

Slide 7 text

*NBHF7JFX w Drawable Λදࣔ͢ΔͨΊͷView ௨ৗͷ View ͷ background Ͱ΋දࣔͰ͖Δ͕ɺେ͖͞มߋͳͲ͕Ͱ͖ͳ͍.

Slide 8

Slide 8 text

"OESPJEͷը૾ͷදݱ • Bitmap w ը૾Λද͢ • Drawable w ʮը໘ʹදࣔ͞ΕΔ΋ͷʯΛද͢ w ը૾͔΋͠Εͳ͍͠ɺͨͩͷ৭͔΋͠Εͳ͍ w ImageView΍എܠͰදࣔ͞ΕΔͷ͸͜Ε

Slide 9

Slide 9 text

"OESPJEͷը૾ͷදݱ "OJNBUJPO
 %SBXBCMF #JUNBQ $PMPS "OJNBUJPO #JUNBQ%SBXBCMF $PMPS%SBXBCMF %SBXBCMF $POWFSU

Slide 10

Slide 10 text

ը૾Λ഑ஔ • res/drawable/ ʹ Drawable Λઃஔ͢Δ w ࠓճ͸ը૾ 1/('JMF w 9.-Ͱهड़͢Δ͜ͱ΋Մೳ w ௚઀ϑΝΠϧΛίϐʔ͢ΔPS
 "OESPJE4UVEJPܦ༝Ͱίϐʔ͢Δ ղ૾౓ผʹ࠷దͳը૾Λ༻ҙ͢Δ͜ͱ΋Ͱ͖Δ (drawable-hdpi ͳͲ)

Slide 11

Slide 11 text

഑ஔྫ

Slide 12

Slide 12 text

ը૾Λදࣔ • android:src • ImageView Ͱදࣔ͢Δ Drawable Λઃఆ

Slide 13

Slide 13 text

ը૾Λදࣔ

Slide 14

Slide 14 text

ը૾Λදࣔ w ิ଍ w android:scaleTypeͰը૾ͷ֦େํ๏Λબ΂Δ w ৄࡉ͸লུ

Slide 15

Slide 15 text

-BZPVU
 GSPN+BWB

Slide 16

Slide 16 text

+BWBͰͷϨΠΞ΢τ w 9.-ʹॻ͍͍֤ͯͨView͸+BWBͷΫϥε • TextView -> android.widget.TextView • EditText -> android.widget.EditText
 • શͯ View ΫϥεͷࢠΫϥε XML Ͱ͸ android.widget ʹ͋Δ View ͸ಛผʹύοέʔδ໊ΛলུͰ͖͍ͯͨ.
 ಠࣗͷ View ͷ৔߹লུͰ͖ͳ͍.

Slide 17

Slide 17 text

7JFXͷຊ࣭͸+BWB w 7JFXͷॳظԽ͸7JFXͷίϯετϥΫλͰ։࠵ 9.-Λύʔεʢղੳʣ 7JFXͷॳظԽॲཧΛ࣮ߦ ɾ ྫandorid:text#setText(…)

Slide 18

Slide 18 text

7JFXΛऔಘ

Slide 19

Slide 19 text

7JFXΛऔಘ • View #findViewById(int id) w Activity΍ViewGroupʹੜ͑ͯΔ w ࢦఆͨ͠idͷViewΛऔಘ

Slide 20

Slide 20 text

7JFXΛऔಘ * MainActivity.java // setContentView લʹߦ͏ͱ View ͕औಘͰ͖ͳ͍ setContentView(R.layout.activity_main); EditText editText = (EditText) findViewById(R.id.post_edit); Button submitButton = (Button) findViewById(R.id.post_button);

Slide 21

Slide 21 text

* MainActivity.java // setContentView લʹߦ͏ͱ View ͕औಘͰ͖ͳ͍ setContentView(R.layout.activity_main); EditText editText = (EditText) findViewById(R.id.post_edit); Button submitButton = (Button) findViewById(R.id.post_button); 7JFXΛऔಘ *%͕FEJU@UFYUͷ7JFXΛऔಘ

Slide 22

Slide 22 text

* MainActivity.java // setContentView લʹߦ͏ͱ View ͕औಘͰ͖ͳ͍ setContentView(R.layout.activity_main); EditText editText = (EditText) findViewById(R.id.post_edit); Button submitButton = (Button) findViewById(R.id.post_button); 7JFXΛऔಘ &EJU5FYUʹΩϟετͯ͠୅ೖ findViewById ͷฦΓ஋͸ View ݻఆͳͷͰΩϟετ͢Δඞཁ͕͋Δ

Slide 23

Slide 23 text

7JFXΛ
 +BWB͔Βૢ࡞

Slide 24

Slide 24 text

7JFXΛૢ࡞ w 7JFXͷؔ਺ΛݺͿ͜ͱͰૢ࡞͕Մೳ editText.setHint(“KMC"); editText.setVisibility(View.GONE); imageView.setImageResource(R.drawable.kirby); // pixel ୯ҐͳͷͰ஫ҙ submitButton.setWidth(300); // ॻ͔Εͨจࣈྻ͕ฦͬͯ͘Δ editText.getText();

Slide 25

Slide 25 text

w ͓͢͢Ί͠·ͤΜ w දࣔ͢Δ͚ͩͷίʔυ͕௕͘ෳࡶʹͳΔ w ࣮ࡍ΍ͬͯΔਓ΋͍Δ͚Ͳʜ w දࣔͷઃఆͱڍಈͷઃఆ͸෼͚͍ͨ
 w 9.-ʹॻ͚Δ෦෼͸ॻ͘͜ͱ͕ଟ͍ શ෦+BWBͰॻ͚͹ศརʁ

Slide 26

Slide 26 text

ΫϦοΫ࣌ͷڍಈ

Slide 27

Slide 27 text

ΫϦοΫ࣌ͷڍಈ • View#setOnClickListener(
 OnClickListener listener) • ΫϦοΫ͞Εͨ࣌ʹݺ͹ΕΔϦεφΛઃఆ͢Δ • View.OnClickListener Λઃఆ
 • View.OnCliclListener ͱ͸ʁ

Slide 28

Slide 28 text

7JFX0O$MJDL-JTUFOFS w ϝιου͕Ұͭઃఆ͞ΕͨΠϯλʔϑΣʔε w ΫϦοΫ࣌ʹonClick͕ݺͼग़͞ΕΔ * View.java (Android SDK) public interface OnClickListener { void onClick(View v); }

Slide 29

Slide 29 text

ΫϦοΫͰτʔετ

Slide 30

Slide 30 text

* MainActivity.java submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), “clicked!”, Toast.LENGTH_LONG ).show(); } } ); ϘλϯΫϦοΫͰτʔετɹ

Slide 31

Slide 31 text

* MainActivity.java submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), “clicked!”, Toast.LENGTH_LONG ).show(); } } ); ϘλϯΫϦοΫͰτʔετɹ 0O$MJDL-JTUFOFSͷແ໊ΦϒδΣΫτ

Slide 32

Slide 32 text

* MainActivity.java submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), “clicked!”, Toast.LENGTH_LONG ).show(); } } ); ϘλϯΫϦοΫͰτʔετɹ ΫϦοΫ͢Δͱݺ͹ΕΔؔ਺

Slide 33

Slide 33 text

* MainActivity.java submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), “clicked!”, Toast.LENGTH_LONG ).show(); } } ); ϘλϯΫϦοΫͰτʔετɹ τʔετΛදࣔ

Slide 34

Slide 34 text

ϘλϯΫϦοΫͰτʔετɹ ˠ Click

Slide 35

Slide 35 text

ઃఆ஋อଘ

Slide 36

Slide 36 text

ઃఆ஋อଘ w ͍͔ͭ͘ͷํ๏͕͋Δ w 4IBSFE1SFGFSFODF w ࠓճ΍Γ·͢ w 4RMJUF σʔλϕʔε w ֎෦ϥΠϒϥϦ

Slide 37

Slide 37 text

4IBSFE1SFGFSFODF w ઃఆ஋ͳͲΛอଘ͢Δ࢓૊Έ w ΩʔόϦϡʔܗࣜͰอଘ w த਎͸9.- w อଘͰ͖Δܕ͸ݶΒΕ͍ͯΔ • int, long, float, boolean, String, Set

Slide 38

Slide 38 text

4IBSFE1SFGFSFODF w ෳ਺ͷ9.-ϑΝΠϧʹอଘͰ͖Δ w ϑΝΠϧ͝ͱʹΩʔ໊͸Ұҙ w ࠓճ͸σϑΥϧτͷ9.-ϑΝΠϧΛ࢖༻ w ϑΝΠϧΛؒҧ͑ͯϋϚΒͳ͍Α͏ʹ w ؒҧ͑ͯެ։͞ΕΔ͜ͱ͕ͳ͍Α͏ʹ w ઃఆʹΑͬͯ͸ଞͷΞϓϦͰ΋ಡΈऔΕͯ͠·͏

Slide 39

Slide 39 text

4IBSFE1SFGFSFODF • σϑΥϧτͷ SharedPreferences Λऔಘ • ϑΝΠϧ͝ͱͷઃఆ (SharedPreference) 
 Λ؅ཧ͢ΔΫϥε SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Static ϝιου

Slide 40

Slide 40 text

4IBSFE1SFGFSFODFT w อଘ sharedPreferences.edit() .putInt("hoge", 1) .putString("piyo", "piyoipyo") .putBoolean("foo", true) .apply();

Slide 41

Slide 41 text

4IBSFE1SFGFSFODFT w อଘ sharedPreferences.edit() .putInt("hoge", 1) .putString("piyo", "piyoipyo") .putBoolean("foo", true) .apply(); 4IBSFE1SFGFSFOFT&EJUPSΛऔಘ

Slide 42

Slide 42 text

w อଘ sharedPreferences.edit() .putInt("hoge", 1) .putString("piyo", "piyoipyo") .putBoolean("foo", true) .apply(); 4IBSFE1SFGFSFODFT Ωʔͱ஋Λ֨ೲ put~~~ ͷฦΓ஋͸ editor ࣗ਎ͳͷͰ͜ͷΑ͏ʹॻ͚Δ ʢνΣʔϯϝιουͱ͍͏ʣ.

Slide 43

Slide 43 text

w อଘ sharedPreferences.edit() .putInt("hoge", 1) .putString("piyo", "piyoipyo") .putBoolean("foo", true) .apply(); 4IBSFE1SFGFSFODFT ઃఆΛ൓ө commit() ͸ಉظతͰ͕͔͔࣌ؒΔͷͰඇਪ঑

Slide 44

Slide 44 text

4IBSFE1SFGFSFODFT w औΓग़͠ sharedPreferences.getInt("hoge", 0); sharedPreferences.getString("piyo", null); sharedPreferences.getBoolean("foo", false); ΩʔͱσϑΥϧτ஋Λࢦఆ