Android开发布局 案例二
实践案例:

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:orientation="vertical"
tools:context="登录">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/UserName"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="请输入用户名" />
<android.support.v7.widget.AppCompatEditText
android:id="@+id/UserPassWord"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="请输入密码" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/Login"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="登录" />
<TextView
android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="记住密码" />
</LinearLayout>
Java
package com.example.administrator.demo2;
import android.app.AlertDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
//调用父类的onCreate方法
super.onCreate(savedInstanceState);
//设置layout中对应的XML文件activity_main
setContentView(R.layout.activity_main);
//获取登录按钮
Button ligin_button = (Button) findViewById(R.id.Login);
//获取文本框控件
final EditText userName_edt = (EditText) findViewById(R.id.UserName);
final EditText userPass_edt = (EditText) findViewById(R.id.UserPassWord);
//设置“登录”按钮的监听事件
ligin_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userName = userName_edt.getText().toString();
String userPass = userName_edt.getText().toString();
//获取Text控件
TextView tv = (TextView) findViewById(R.id.TextView);
//设置Text为本两个文本框的内容
tv.setText("您的用户名是:"+userName+"密码是:"+userPass);
//设置点击登录按钮后跳转到其他地方
Intent it = new Intent();
it.setClass(MainActivity.this,Main2Activity.class);
startActivity(it);
}
});
}
}
Android开发布局 案例二的更多相关文章
- Android开发布局 案例一
权重:就是在布局界面中所占的比例 实践案例: <?xml version="1.0" encoding="utf-8"?> <LinearLa ...
- Android实训案例(二)——Android下的CMD命令之关机重启以及重启recovery
Android实训案例(二)--Android下的CMD命令之关机重启以及重启recovery Android刚兴起的时候,着实让一些小众软件火了一把,切水果,Tom猫,吹裙子就是其中的代表,当然还有 ...
- Android开发——通过扫描二维码,打开或者下载Android应用
Android开发——通过扫描二维码,打开或者下载Android应用 在实现这个功能的时候,被不同的浏览器折磨的胃疼,最后实现了勉强能用,也查考了一下其他人的博客 android实现通过浏览器点击 ...
- Xamarin.Android开发实践(二)
原文:Xamarin.Android开发实践(二) 一.准备 开始学习本教程前必须先完成该教程http://www.cnblogs.com/yaozhenfa/p/xamarin_android_qu ...
- 教我徒弟Android开发入门(二)
前言: 上一期实现了简单的QQ登录效果,这一期继续对上一期进行扩展 本期的知识点: Toast弹窗,三种方法实现按钮的点击事件监听 正文: Toast弹窗其实很简单,在Android Studio ...
- Android开发学习总结(二)——使用Android Studio搭建Android集成开发环境
有很长一段时间没有更新博客了,最近实在是太忙了,没有时间去总结,现在终于可以有时间去总结一些Android上面的东西了,很久以前写过这篇关于使用Android Studio搭建Android集成开发环 ...
- Android开发——布局性能优化的一些技巧(一)
0. 前言 上一篇我们分析了为什么LinearLayout会比RelativeLayout性能更高,意义在于分析了这两种布局的实现源码,算是对一个小结论的证明过程,但是对布局性能的优化效果,对这两种布 ...
- [转]浅谈Android五大布局(二)——RelativeLayout和TableLayout
在浅谈Android五大布局(一)中已经描述了LinearLayout(线性布局).FrameLayout(单帧布局)和AbsoulteLayout(绝对布局)三种布局结构,剩下的两种布局Relati ...
- Android开发--布局二
1.Andrid:控件布局(表格布局)TableLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 ...
随机推荐
- linux之wc命令详解
Linux系统中wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 1.命令格式 wc [options] 文件... 2.命令功能 统计指定文件中的字 ...
- Android 百度地图用法
一.展示百度地图,并将一个指定的点(根据经纬度确定)展示在手机屏幕中心 1.下载百度地图移动版API(Android)开发包 要在Android应用中使用百度地图API,就要在工程中引入百度地图API ...
- 在调用系统相册时,UIIMagePickerController使用中偷换StatusBar颜色的问题
在调用系统相册时,UIIMagePickerController使用中偷换StatusBar颜色的问题 此时解决办法是 #pragma mark - UIImagePickerController D ...
- zabbix之监控Nginx连接数
#;下载Nginx (编译的时候必须加上此选项 --with-http_stub_status_module) 官网地址:http://nginx.org/en/docs/http/ngx_http_ ...
- Spring(1):Spring介绍
一,Spring简介: Spring是一个开源框架,它由Rod Johnson创建:它是为了解决企业应用开发的复杂性而创建的 Spring是一个轻量级的控制反转(IOC)和面向切面(AOP)的容器框架 ...
- entfrm-app赋能entfrm零代码开发平台 开启多平台分发
entfrm-app是基于uni-app 框架.使用 Vue.js 语法开发的移动端 App开源产品.它可以编译为 H5.IOS App.Android App.微信小程序.QQ小程序.钉钉小程序.支 ...
- eclipse.ini配置 vmargs 说明
-vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M 1. 各个参数的含义什么? 参数中-vmargs的意思是设置JVM参数, ...
- DMA(Data Migration Assistant)迁移SQLServer数据库
DMA适用于 本地SQLServer向Azure SQL Database迁移 两台不同的数据库服务器之间迁移 高版本->低版本 或 低版本->高版本 本文以两台不同服务器的低版本(SQL ...
- [BUUCTF]PWN21——ciscn_2019_s_3
[BUUCTF]PWN21--ciscn_2019_s_3 附件 步骤 例行检查,64位,开启了NX保护 试运行的时候回显是一些乱码,直接用ida打开,从main函数开始看 main函数调用了vuln ...
- SpringBoot 2.x 自定义拦截器并解决静态资源访问被拦截问题
自定义拦截器 /** * UserSecurityInterceptor * Created with IntelliJ IDEA. * Author: yangyongkang * Date: ...