【Android講座】第0回 趣旨説明、AndroidStudioの導入とアプリ作成
本講座の背景・目的・目標
◆背景
開発初心者がAndroidを体系的に学べる教材がなかったので、なんとかしたい。
◆目的
◆目標
- Androidアプリを一人で作れるようになる
※注意点
本講座で使う開発言語は、現時点でjava
になります。
今後、Androidの体系化が進んでいく中で、kotlin
やFlutter
への展開も行いたいと考えています。
Android Studioのインストール
アプリの作成
- Android Studioを起動
Create New Project
を押下- プロジェクトの情報を入力して、
Finish
を押下
Name:AndroidLesson
PackegeName :com.examle
Save location : 任意
Language :java
Minuimum SDK :API 26
Empty Activity
を選択して、Finish
を押下
Emulatorの導入
※例)Pixel 4
- Toolsタブ > AVD Mangerを選択
+ Create Virtual Device...
を押下- Phone > Pixel 4を選択して、
Next
を押下 - System Image(AndroidのVer)を選択、Downloadして、
Next
を押下 - 名前を決めて、
Finish
を押下 - 作成したEmulatorの三角ボタンを押下して、起動
Androidの3大ファイルについて
※EmptyActivityのファイルの中身を確認
AndroidManifes
AndroidManifes.xml
を見る
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AndroidLesson"> <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>
javaファイル
MainActivity.java
を見る
package com.example; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
resファイル
drawable
画像を管理するフォルダ
layout
画面のレイアウトを管理するフォルダ
activity_main.xml
を見る
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout>
values
画面の文字や色やテーマを管理するフォルダ
strings.xml
を見る
<resources> <string name="app_name">AndroidLesson</string> </resources>
アプリの実行
Empty Activityを作成するとHello Worldと画面に表示するアプリが最初から作られています。
- Emulatorを指定して、緑三角のボタンを押下
→アプリのインストールを行ってくれます
まとめ
- AndroidStudioのインストールをしました。
- 今後Androidを勉強していくアプリを作成しました。
- Emulatorの作成とアプリが実行できるようにしました。