比率変更

新章突入。アプリ起動時に実行されるメソッド。

前回はこちら。

 前回までの流れは一応解決としまして、今回は新規プロジェクトの作成からです。

  まずは前回までのプロジェクトを閉じます。

 初期画面から、改めて新規プロジェクトの開始を選択し必要事項を入力していきます。HelloSample、と。プロジェクトが立ち上がったら、まずはres/values/string.xmlの内容を書き換え。

<?xml version="1.0"  encoding="utf-8"?>
<resources>
 <string name="app_name">イベントとリスナサンプル</string>
 <string name="tv_name">お名前を入力してください</string>
 <string name="bt_click">表示</string>
</resources>

 さらにactivity_hello_sample.xmlを書き換えていきます。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/tv_name"/>

    <EditText
        android:id="@+id/etName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"/>

    <Button
        android:id="@+id/btClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/bt_click"/>

    <TextView
        android:id="@+id/tvOutput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:text=""
        android:textSize="25sp"/>

</LinearLayout>

 デザインモードとエミュレータで確認してみます。

 エミュレータとデザインモードで入力部分の色が違うのは仕様でしょうか。今までが今までだけに、あっさりうまく行きすぎな気がしてしまいます。このあとテキストではしばらく解説が続きました。重要なことだろうことは分かりますが、内容の半分も理解できている気がしません。次回はイベントリスナ、ついにタッチパネルの制御に入るようです。

つづく!

ここから先は

0字

¥ 100

期間限定 PayPay支払いすると抽選でお得に!

この記事が気に入ったらサポートをしてみませんか?