Android常见控件— — —EditText
<?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的更多相关文章
- Android -- 常见控件的小效果
1,EditText控件 ① 修改光标颜色 自定义drawable 创建cursor.xml文件 <?xml version="1.0" encoding="utf ...
- android 基础控件 EditText
EditText 简介: EditText 控件继承 TextView ,它有TextView的所有属性和方法,并且自身是可编辑的: extends TextView java.lang.Object ...
- Android输入控件EditText和软键盘监听
1. 跳转到新的页面自动软键盘显示情况: 在配置清单文件AndroidManifest.xml文件,对Activity的windowSoftInputMode属性进行设置. stateUnspecif ...
- Android基础控件EditText
1.常用属性 <!--selectAllOnFocus 获得焦点后全选组件内所有文本内容--> <!--inputType 限制输入方式--> <!--singleLin ...
- Android --> 常见控件
1.TextView 主要用于界面上显示一段文本信息 2.Button 用于和用户交互的一个按钮控件 //为Button点击事件注册一个监听器public class Click extends ...
- Android常见控件— — —ProgressDialog
package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...
- Android常见控件— — —AlertDialog
package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...
- Android常见控件— — —ProgressBar
ProgressBar用于在界面上显示一个进度条,表示我们的程序正在加载一些数据. <?xml version="1.0" encoding="utf-8" ...
- Android常见控件— — —Button
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...
随机推荐
- 使用C# yield关键字来提高性能和可读性
对于”yield”这个关键字我已经见过N次了,直到最近我才知道这个关键字所蕴含的力量.我将在下面展示出一些使用”yield”让你的代码有更高可读性和更好性能的例子. 为了让你对yield有一些快速概览 ...
- linux下安装及配置和启动memcached
一.下载文件: 下载memcached和libevent,放到/hom/zwl/目录下 # wget http://www.danga.com/memcached/dist/memcached-1.2 ...
- python matplotlib 中文显示参数设置
python matplotlib 中文显示参数设置 方法一:每次编写代码时进行参数设置 #coding:utf-8import matplotlib.pyplot as pltplt.rcParam ...
- Ubuntu Linux 12.04 LTS amd64系统本地root提权
URL:http://www.ichunqiu.com/section/173 由于fusermount二进制调用setuid的(geteuid())重置RUID时,它调用/bin/mount才能使用 ...
- package
1.设计package原因 理解基目录的概念,思考jre加载class的顺序,如果没有package会怎么样?有了之后又是怎么样..? 主要:确保类名的唯一性. 次要:方便组织代码 2.怎样访问\导入 ...
- shiro的Helloworld
package shiro; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePassword ...
- 1 Spring MVC 原理
1. 注解式 Spring MVC 响应流程: 重要的接口和类的简单说明: DispatcherServlet:前端控制器,用于接收请求. HandlerMapping接口:用于处理请求的映射. D ...
- linux -- 基于mysql tomcat 部署web项目
一.导入数据库 二.配置web项目访问端口 vim /var/lib/tomcat8/conf/server.xml <Connector port=" protocol=" ...
- gitgub利用客户端实现简单的上传和同步
新建项目 打开客户端(将项目拷贝到本地) 选择要clone到的文件夹 想该文件夹中,导入自己需要上传的代码 然后,在网站上登录自己的gitgub,就可以看到刚才上传的项目了╮(╯▽╰)╭
- 支持向量机(SVM)算法