<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <EditText
android:id="@+id/edit_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="请输姓名"
android:maxLines="1"/> <EditText
android:id="@+id/edit_test2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:hint="学号"
android:maxLines="1"/> </LinearLayout>


应用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <EditText
android:id="@+id/edit_test1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="请输姓名"
android:maxLines="1"/> <EditText
android:id="@+id/edit_test2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:hint="请输入学号"
android:maxLines="1"/> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"
android:layout_gravity="center"
/> </LinearLayout>


package com.example.uiwidgettest2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*; public class edittextActivity extends Activity implements View.OnClickListener{ private EditText et1;
private EditText et2;
private Button btn; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edittext);
btn = (Button)findViewById(R.id.button1);
et1 = (EditText)findViewById(R.id.edit_test1);
et2 = (EditText)findViewById(R.id.edit_test2);
btn.setOnClickListener(this);
} @Override
public void onClick(View v) {
switch (v.getId()){
case R.id.button1:
String username = et1.getText().toString();
String id = et2.getText().toString();
Toast.makeText(edittextActivity.this,username+id,Toast.LENGTH_SHORT).show();
break;
default:
break;
}
}
}

												

Android常见控件— — —EditText的更多相关文章

  1. Android -- 常见控件的小效果

    1,EditText控件 ① 修改光标颜色 自定义drawable 创建cursor.xml文件 <?xml version="1.0" encoding="utf ...

  2. android 基础控件 EditText

    EditText 简介: EditText 控件继承 TextView ,它有TextView的所有属性和方法,并且自身是可编辑的: extends TextView java.lang.Object ...

  3. Android输入控件EditText和软键盘监听

    1. 跳转到新的页面自动软键盘显示情况: 在配置清单文件AndroidManifest.xml文件,对Activity的windowSoftInputMode属性进行设置. stateUnspecif ...

  4. Android基础控件EditText

    1.常用属性 <!--selectAllOnFocus 获得焦点后全选组件内所有文本内容--> <!--inputType 限制输入方式--> <!--singleLin ...

  5. Android --> 常见控件

    1.TextView  主要用于界面上显示一段文本信息 2.Button  用于和用户交互的一个按钮控件 //为Button点击事件注册一个监听器public class Click extends ...

  6. Android常见控件— — —ProgressDialog

    package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...

  7. Android常见控件— — —AlertDialog

    package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...

  8. Android常见控件— — —ProgressBar

    ProgressBar用于在界面上显示一个进度条,表示我们的程序正在加载一些数据. <?xml version="1.0" encoding="utf-8" ...

  9. Android常见控件— — —Button

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...

随机推荐

  1. Android 网络请求库volley的封装,让请求更方便

    首先封装一下volley 请求 public class CustomRequest extends StringRequest { private static final String TAG = ...

  2. mac上安装Navicat Premium 破解版+汉化包

    Navicat是一款非常强大的sql分析管理工具.以前一直在windows上面使用. 由于工作的需要,我也是折腾出了这不易的mac破解版.下了好多网上的版本,亲测这个可用. 俗话说:工欲善其事,必先利 ...

  3. adpatch options=hotpatch

    --no need to shutdown application and no need to enable maintenance mode adpatch options=hotpatch fi ...

  4. log4j日志不输出MyBatis SQL脚本?

    日志输出级别调成debug,然并卵? 试试加下这个包. <dependency> <groupId>org.slf4j</groupId> <artifact ...

  5. Knights of the Round Table-POJ2942(双连通分量+交叉染色)

    Knights of the Round Table Description Being a knight is a very attractive career: searching for the ...

  6. python简单实现用户表单登录

    实现简单的用户表单验证登录 user="desperado" pwd=" s=0 for i in range(10): if s < 3: username = ...

  7. R----lubridata包介绍学习

    lubridate包,非常强大,能够识别各种类型的日期.字符型和时间型数据,都是格式比较特别的你数据,在处理时,比较麻烦,但是有了lubridate这个包之后,时间处理变得非常简单,这个包函数命名简单 ...

  8. jquery之empty()方法详解

    empty()函数用于清空每个匹配元素内的所有内容. empty()函数将会移除每个匹配元素的所有子节点(包括文本节点.注释节点等所有类型的节点). 该函数属于jQuery对象(实例). 语法 jQu ...

  9. [php] php图表显示

    使用jpgragh绘制php图表, 下载地址http://jpgraph.net/download/ 1> 服务器环境centos6.5, php5.0. 2> linux环境下需要配置j ...

  10. linux复习

    linux的特点           - 免费的/开源           - 支持多线程/多用户           - 安全性好           - 对内存和文件管理优越       关机命令 ...