Android
多くのリスナーは一度だけ使われることが多いので、匿名型が相応しいのだ。事実上、現在最も使われる方式である。*Layoutは省略。 MainActivity.java package com.example.liguofeng.anonymouslistner;import android.support.v7.app.AppCompatActivity;imp…
①ActivityがListnerを継承し②メソッドをオーバライドするこの方法のデメリット ① Activityは画面初期化の役割が多いが、リスナーを作るのはよくないな。② そもそもActivityがListnerのインタフェースを実装するのがおかしいな。*Layoutは省略。 MainActivit…
①外部クラスでリスナーを生成し②リスナーをViewに登録する。一般的には外部クラスでリスナー生成はしない。 理由としては主に①イベントは特定のGUI画面に所属するものなので、外部クラスにするのは集約面でよくない②外部クラスでリスナーを生成すると自由にE…
①内部クラスでリスナーを生成し②リスナーをViewに登録する。*Layoutは省略。 MainActivity.java package com.example.liguofeng.innerclass;import android.support.v7.app.AlertDialog;import android.support.v7.app.AppCompatActivity;import android.os…
Androidアプリにおいて最も重要な一つがイベント処理です。 たとえば、ボタンがクリックされたり、スライドしたりした場合、 その動作をキャッチして処理を行うのがイベント処理です。 Androidの場合、大きく二つの方法でイベント処理を行います。 1.リス…
activity_main.xml
activity_main.xml
activity_main.xml
AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.xxxxx.menutoactivity" > </manifest>
activity_main.xml
activity_main.xml
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal"> </linearlayout>
activity_main.xml
activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > </relativelayout>
activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </relativelayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </relativelayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </linearlayout>
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > </linearlayout>