さて、やっとAndroidアプリ開発っぽいところに入ります。
まずはxmlでレイアウト(画面に何がどう表示されるか)を設定します。
とりあえずサイドメニューは置いて置いて、メインのリストを作っていきます。
activity_main.xml
メインの画面のレイアウトを設定。
Constraint Layoutというのが新しくできたらしくデフォではそれになっていますがちょっと使い方がわからな過ぎたので今回は一旦LinearLayoutでさらっと。
画面いっぱいにListViewを置いただけです。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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="net.rensyuu.mytodo.MainActivity"> <ListView android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> |
task_list_item.xml
タスクのリストに表示されるアイテムのレイアウト。
とりあえずチェックボックスを置いただけです。手抜きじゃ無いよ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightSum="1"> <CheckBox android:id="@+id/checkBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="CheckBox" /> </LinearLayout> |
簡単ですね。
次はmodelを作ります。
ではまた。
参考書籍:
1から勉強するのにおすすめでした。(プログラミング経験は無いときつそう)