编辑文本(EditText)
今天要给大家介绍的是简单的编辑文本框;
先看一下它的基本属性:

1.Activity
public class EditTextActivity extends Activity {
    private EditText nameEditText;
    private EditText passwordEditText;
    private EditText ageEditText;
    private Button button;
//编辑文本
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_text);
        nameEditText = (EditText)findViewById(R.id.nameEditTextId);
        passwordEditText = (EditText)findViewById(R.id.passwordEditTextId);
        ageEditText = (EditText)findViewById(R.id.ageEditTextId);
        button = (Button)findViewById(R.id.buttonId);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                //获取你输入的姓名,密码,年龄
                String name = nameEditText.getText().toString().trim();
                String password = passwordEditText.getText().toString().trim();
                String ageString = ageEditText.getText().toString().trim();
                //用于提示消息
                Toast.makeText(EditTextActivity.this, "name="+name+"\r\npassword="+password+
                        "\r\nage="+ageString, Toast.LENGTH_LONG).show();
            }
        });
    }
}
2.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"
android:padding="5dp" > <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="姓名:"
android:textSize="20sp" /> <EditText
android:id="@+id/nameEditTextId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="密码:"
android:textSize="20sp" /> <EditText
android:id="@+id/passwordEditTextId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:inputType="textPassword" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="年龄:"
android:textSize="20sp" /> <EditText
android:id="@+id/ageEditTextId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入年龄"
android:inputType="number"
android:maxLength="3" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="不可编辑"
android:textSize="20sp" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:hint="这里的内容不可以被更改" /> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="不可获取焦点(也不可以编辑)"
android:textSize="20sp" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:hint="这个输入框获取不到焦点" /> <Button
android:id="@+id/buttonId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示用户所填写的信息" /> </LinearLayout>
3.效果图如下:

编辑文本(EditText)的更多相关文章
- 使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析
		
使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析 因为我在前台使用了jquery的text()方法,而不是html ...
 - 将HTML文本框设为不可编辑文本框。
		
将HTML文本框设为不可编辑文本框. 方法1: onfocus=this.blur() <input type="text" name="input1" ...
 - Flask学习记录之MarkDown编辑文本
		
为了让网页支持markdown编辑文本,使用如下了4个库 PageDown : 在前端提供一个可以实时将markdown内容转换成html文本进行效果预览的编辑器 Flask-PageDown: 这个 ...
 - 小程序实践(十):textarea实现简单的编辑文本界面
		
textarea是官方的原生组件,用于多行输入 简单的例子,监听文本内容.长度,以及设置最大可输入文本长度 wxml <view class='textarea-Style'> <t ...
 - 如何使用ABBYY FineReader 12将JPEG文件转换成可编辑文本
		
日常工作中,经常会收到一些JPEG格式的图像文件,有时候还需要做一些修改,可是大家都知道JPEG格式的文件是无法修改的,必须转换成可编辑的格式,当然,现在市场上也应用而生了很多转换工具,相信大家都听说 ...
 - java实现在图片上编辑文本内容
		
package com.yin.text; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; impor ...
 - Xamarin iOS教程之显示和编辑文本
		
Xamarin iOS教程之显示和编辑文本 Xamarin iOS显示和编辑文本 在一个应用程序中,文字是非常重要的.它就是这些不会说话的设备的嘴巴.通过这些文字,可以很清楚的指定这些应用程序要表达的 ...
 - ubuntu上使用vim编辑文本内容
		
1. 什么是 vim? Vim是从 vi 发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用.简单的来说, vi 是老式的字处理器,不过功能已经很齐全了, ...
 - IOS Runtime属性关联实现表格编辑文本
		
要实现在表格里编辑文本, 表格让我想到了CollectionView,文本让我想起TextView, 做之前想了好久怎么样来获得编辑的是哪个TextView,要获取对应的IndexPath啊,想着之前 ...
 
随机推荐
- Mysql备份之Innobakcupex&Xtrabackup
			
一.innobackupex备份工具 基本选项 --compress:该选项表示压缩innodb数据文件的备份. --compress-threads:该选项表示 ...
 - linux下不同颜色文件的性质
			
绿色文件: 可执行文件,可执行的程序 红色文件:压缩文件或者包文件 蓝色文件:目录 白色文件:一般性文件,如文本文件,配置文件,源码文件等 浅蓝色文件:链接文件,主要是使用ln命令建立的文件 红色闪烁 ...
 - netty用户指南
			
Netty用户指南 一.前言 1.问题 当今世界我们需要使用通用的软件或库与其他组件进行通信,例如使用HTTP客户端从服务器中获取信息,或通过网络服务调用一个远程的方法.然而通用的协议及其实现通常不具 ...
 - 深入了解Looper、Handler、Message之间关系
			
深入了解Looper.Handler.Message之间关系 前言及简介 上个星期我们整个项目组趁着小假期,驱车去了江门市的台山猛虎峡玩了两个多钟左右极限勇士全程漂流,感觉真得不错,夏天就应该多多玩水 ...
 - Mac 10.12安装SecureCRT
			
下载: (链接: https://pan.baidu.com/s/1eSNBoFC 密码: sztc) 安装参考: http://www.cnblogs.com/EasonJim/p/7568734. ...
 - 使用nginx反向代理jenkins
			
1.在Jenkins 官方网站(http://jenkins-ci.org/)下载最新版本war包.拷贝到 $TOMCAT_HOME/webapps 下(不用解压).启动tomcat服务. 2.找到n ...
 - python-wsgi测试服务器
			
#!/usr/bin/python from wsgiref.simple_server import make_server def application(environ,start_respon ...
 - seajs模块路径解析 简单总结
			
最近在试着用 seajs + grunt 搭建项目雏形, 遇到的最大的问题就是 seajs 命名与调用, 简单总结一下. 模块调用 seajs中调用模块有两种方式,seajs.use(ID) . re ...
 - 【LeetCode题解】144_二叉树的前序遍历
			
目录 [LeetCode题解]144_二叉树的前序遍历 描述 方法一:递归 Java 代码 Python 代码 方法二:非递归(使用栈) Java 代码 Python 代码 [LeetCode题解]1 ...
 - 动态生成自定义控件ascx如何给ascx传值
			
有机会看到有网友在论坛上发出问题: 在网页上的铵钮执行之后,动态加载的用户控件,如果没有处理好,会在子用户控件的铵钮被执行时抛弃.因此我们需要着重需要处理的关键点.同相子用户控件在动态加载之后,它的状 ...