Android实验——实验1 用户界面:线性布局

该实验旨在理解Android布局管理器,重点掌握线性布局。要求设计一个电子邮件APP模拟程序,包括用户登录和发送邮件功能。通过XML布局资源,使用EditText、Button和TextView创建UI,并在Java代码中实现事件监听器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实验1 用户界面:线性布局

一、实验目的

1、理解Android布局管理器及其属性,掌握线性布局用户界面(UI)的设计方法。
2、掌握在XML文件和Java代码中访问字符串、数组、颜色和尺寸等资源的方法。
3、掌握在Java代码中获取UI控件对象及事件处理的方法。

二、实验要求

设计并实现一个电子邮件APP的模拟程序,完成用户登录和发送邮件的功能,具体要求如下:
1. 定义字符串数组资源,保存可登录的用户。
2. 采用线性布局定义XML布局资源,使用EditText、Button和TextView控件定义用户界面。
3. 在Activity类中,获取控件对象,采用匿名类为相关控件添加事件监听器,完成事件处理。
4. 使用Toast对象显示相关运行信息。

效果

效果

三、实验内容

acticty_main.xml

<?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"
    android:layout_margin="@dimen/side"
    android:orientation="vertical"
    tools:context="cn.yimispace.email.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <EditText
            android:id="@+id/username"
            android:layout_width="0dp"
            android:layout_height=
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值