今天要给大家介绍的是简单的编辑文本框;

先看一下它的基本属性:

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)的更多相关文章

  1. 使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析

    使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析 因为我在前台使用了jquery的text()方法,而不是html ...

  2. 将HTML文本框设为不可编辑文本框。

    将HTML文本框设为不可编辑文本框. 方法1: onfocus=this.blur() <input type="text" name="input1" ...

  3. Flask学习记录之MarkDown编辑文本

    为了让网页支持markdown编辑文本,使用如下了4个库 PageDown : 在前端提供一个可以实时将markdown内容转换成html文本进行效果预览的编辑器 Flask-PageDown: 这个 ...

  4. 小程序实践(十):textarea实现简单的编辑文本界面

    textarea是官方的原生组件,用于多行输入 简单的例子,监听文本内容.长度,以及设置最大可输入文本长度 wxml <view class='textarea-Style'> <t ...

  5. 如何使用ABBYY FineReader 12将JPEG文件转换成可编辑文本

    日常工作中,经常会收到一些JPEG格式的图像文件,有时候还需要做一些修改,可是大家都知道JPEG格式的文件是无法修改的,必须转换成可编辑的格式,当然,现在市场上也应用而生了很多转换工具,相信大家都听说 ...

  6. java实现在图片上编辑文本内容

    package com.yin.text; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; impor ...

  7. Xamarin iOS教程之显示和编辑文本

    Xamarin iOS教程之显示和编辑文本 Xamarin iOS显示和编辑文本 在一个应用程序中,文字是非常重要的.它就是这些不会说话的设备的嘴巴.通过这些文字,可以很清楚的指定这些应用程序要表达的 ...

  8. ubuntu上使用vim编辑文本内容

    1. 什么是 vim? Vim是从 vi 发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用.简单的来说, vi 是老式的字处理器,不过功能已经很齐全了, ...

  9. IOS Runtime属性关联实现表格编辑文本

    要实现在表格里编辑文本, 表格让我想到了CollectionView,文本让我想起TextView, 做之前想了好久怎么样来获得编辑的是哪个TextView,要获取对应的IndexPath啊,想着之前 ...

随机推荐

  1. 利用atimicInteger cas的特性实现一个锁

    利用atimicInteger cas的特性实现一个锁 主要是使用的是 atomicIntegerAPI 的compareAndSet()方法,让线程不在阻塞,获取不到直接失败. 我们先定义一个异常类 ...

  2. 【笔记】AJAX基础

    [笔记]AJAX基础 Django AJAX  知识储备:JSON 什么是 JSON JSON 是轻量级的文本数据交换格式 JSON 独立于语言和平台.JSON 解析器和 JSON 库支持许多不同的编 ...

  3. BLE pairing vs. bonding

    differece between pairing and bonding .see

  4. 2019.04.11 第四次训练 【 2017 United Kingdom and Ireland Programming Contest】

    题目链接:  https://codeforces.com/gym/101606 A: ✅ B: C: ✅ D: ✅ https://blog.csdn.net/Cassie_zkq/article/ ...

  5. WCF系列教程之WCF客户端调用服务

    1.创建WCF客户端应用程序需要执行下列步骤 (1).获取服务终结点的服务协定.绑定以及地址信息 (2).使用该信息创建WCF客户端 (3).调用操作 (4).关闭WCF客户端对象 二.操作实例 1. ...

  6. javascript的JSON对象

    JSON包含用于解析JSON(javascript object notation)的方法,将值转换成JSON.JSON不可以被调用或者用作构造函数. JSON对象保存在大括号内,JSON数组保存在中 ...

  7. 如何修改 linux ubuntu 默认语言

    最近学习linux中,由于安装时选择了简体中文作为默认语言,时常出现乱码现象,所以决定将默认语言改回en_US. 但是在网上找了一些教程,发觉不一定都能实现.现总结如下: (1)对于大部分linux系 ...

  8. CentOS6.4将MySQL5.1升级至5.5.36

    1.为了安全期间,首先需要备份原有数据 2.卸载原有MySQL,先停止原有的MySQL服务,再查找 find / -name mysql [root@qxyw /]# find / -name mys ...

  9. WPF中使用Grid来实现图层的效果

    <Style x:Key="ScanButtonStyle" TargetType="{x:Type Button}"> <!--<Se ...

  10. 利用css实现搜索过滤

    无意中找到一种利用css就可实现的搜索过滤的方法,不得不说看了代码之后确实被惊艳到了,亏我之前面试还因为做这个功能做太慢而拖了后腿.在此记录下代码: <!DOCTYPE html> < ...