Android移动终端设计实验二+事件监听实验

本文主要探讨了Android移动终端的事件监听实验,详细解析了实验二的内容,涵盖了Android事件处理机制的关键知识点。
摘要由CSDN通过智能技术生成

Android移动终端设计实验二+事件监听实验

实验2:事件监听实验


一、     实验目的

本次实验的目的是掌握控件的基于事件监听内部类、基于事件监听内部匿名类、Activity本身作为事件监听器以及直接绑定到标签等四种常用的事件处理方法。

二、     实验环境

Windows7  Eclipse MARS.2  AVD虚拟机

三、实验内容及结果

通过实验1设计的登录对话框掌握android系统的事件监听的几种处理方法。具体要求如下:

            i.      基于事件监听内部类实现事件监听处理;

           ii.      基于事件监听内部匿名类实现事件监听处理;

         iii.      Activity本身作为事件监听器;

           iv.      直接绑定到标签;

            v.      在“登录”按钮事件代码中,判断用户名和密码是否正确。

代码实现和测试结果:

内部类:

代码实现:

Activity_main.xml

<LinearLayoutxmlns:android=

"http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical">

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="欢迎使用登录系统    -by 庞振男"

></TextView>

 

  <LinearLayout

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  >

<TextView

android:id="@+id/user"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="用户名:"/>

<EditText

android:id="@+id/username"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="input username"

 

></EditText>

     </LinearLayout>

     <LinearLayout

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  >

<TextView

android:id="@+id/pass"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="密码:"/>

<EditText

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值