Androidアプリを作る 第5回

9b6ca173883528d3bd047ca8f20b0bce?s=47 nonylene
December 13, 2016

Androidアプリを作る 第5回

9b6ca173883528d3bd047ca8f20b0bce?s=128

nonylene

December 13, 2016
Tweet

Transcript

  1. 7.
  2. 12.

    * MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected

    void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } "DUJWJUZ
  3. 14.

    * MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected

    void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } ىಈ͢Δ࣌ʹݺ͹ΕΔ ίϯετϥΫλͰ Activity ؔ࿈ͷॳظԽΛ͠Α͏ͱ͢Δͱ·ͩॳظԽ͕ࡁΜͰͳ͍͜ͱ͕͋Δ
  4. 15.

    w onCreate()ىಈʢॳظԽॲཧʣ w onStart() ࢝·Δ w ྫىಈ͢ΔɾStopޙ·ͨલ໘ʹ໭ͬͨ w onStop()ࢭ·ͬͨ w

    ྫऴྃ͢Δɾଞͷ"DUJWJUZ͕લ໘ʹग़ͨ w onDestroy() ऴྃ͢Δʢޙย෇͚ʣ ϥΠϑαΠΫϧ
  5. 17.

    * MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected

    void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } ϨΠΞ΢τΛදࣔ R.layout.activity_main ʹؔͯ͠͸ޙड़
  6. 18.

    * AndroidManifest.xml <?xml versi…?> <manifest package=“net.nonylene.myslack" …> <application …> <activity

    android:name=“.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> "OESPJE.BOJGFTUYNM
  7. 21.
  8. 24.

    ໌ࣔత*OUFOU * MainActivity.java Intent intent = new Intent(this, Main2Activity.class); intent.putExtra("name",

    “nonylene"); startActivity(intent); .BJO"DUJWJUZΛىಈ this ͸ Context Ͱɺ͜͜Ͱ͸ MainActivity ࣗ਎ΛೖΕ͍ͯΔ. 
 (Activity ͸ Context ͷࢠΫϥε) Context ͸ΞϓϦͷ؀ڥ৘ใͳͲΛऔಘ͢Δͷʹ࢖ΘΕ͍ͯΔ.
  9. 25.
  10. 26.

    * MainActivity.java Intent intent = new Intent(this, Main2Activity.class); intent.putExtra("name", “nonylene");

    startActivity(intent); ໌ࣔత*OUFOU *OUFOUΛ౤͛Δ .BJO"DUJWJUZ͕ىಈ
  11. 29.

    ҉໧త*OUFOU * MainActivity.java Uri uri = Uri.parse(“https://www.kmc.gr.jp/"); Intent intent =

    new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); 6SJΦϒδΣΫτΛ࡞੒
  12. 30.

    ҉໧త*OUFOU * MainActivity.java Uri uri = Uri.parse(“https://www.kmc.gr.jp/"); Intent intent =

    new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); "$5*0/@7*&8ʢӾཡ͢Δʣͱ։͘6SJΛࢦఆ
  13. 34.
  14. 36.

    งғؾ * activity_main.xml <?xml version="1.0" encoding=“utf-8"?> <RelativeLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="net.nonylene.myslack.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/> </RelativeLayout>
  15. 37.

    งғؾ * activity_main.xml <?xml version="1.0" encoding=“utf-8"?> <RelativeLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="net.nonylene.myslack.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/> </RelativeLayout> શମͷϨΠΞ΢τ
  16. 38.

    งғؾ * activity_main.xml <?xml version="1.0" encoding=“utf-8"?> <RelativeLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="net.nonylene.myslack.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/> </RelativeLayout> 5FYUදࣔ
  17. 39.
  18. 50.

    * MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected

    void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } MBZPVUBDUJWJUZ@NBJOYNMΛදࣔ 3Ϋϥε
  19. 58.

    QBEEJOHNBSHJO w ༨നΛઃఆ͢ΔͨΊͷଐੑ w શମ5PQ #PUUPN 4UBSU  &OE ͕ઃఆͰ͖Δ

    w ݹ͍୺຤Ͱ͸-FGU3JHIUʹͳΔ w ΞϥϏΞޠͳͲٯ޲͖ͷݴޠͰ΋ಉ͡ʹͳΔ
  20. 62.

    7JTJCJMJUZ • android:visibility • ཁૉͷදࣔɾඇදࣔઃఆ • VISIBLE: ݟ͑ΔʢσϑΥϧτʣ • INVISIBLE:

    ݟ͑ͳ͍͕εϖʔε͸औΔʢಁ໌ʣ • GONE: ݟ͑ͳ͍͠εϖʔε΋औΒͳ͍ʢফڈʣ
  21. 63.

    MBZPVU@HSBWJUZ • android:layout_gravity w ਌ͷ7JFXʹରͯ͠Ͳͷ৔ॴʹஔ͔͘ • hoge|piyo ͷΑ͏ʹॎԣͷҐஔΛࢦఆ • top

    / bottom / start / end / center_horizontal / center_vertical • LinearLayout / FrameLayout ޙड़ Ͱ࢖͏
  22. 64.
  23. 76.

    ͍Ζ͍Ζͳଐੑ • android:text / textColor / textSize w จࣈྻɾจࣈ৭ɾจࣈαΠζΛࢦఆ •

    android:background w എܠͷ৭΍ը૾Λࢦఆ • android:hint w &EJU5FYUʹจࣈΛೖΕΔલͷώϯτΛઃఆ