zoukankan      html  css  js  c++  java
  • Android之EditText组件学习

    一、基础学习

    1.Button是TextView的一个子类,所以按钮本身是一个特殊的文本,属性和TextView相似
    2.EditText类似html里的input type="text",是TextView的一个子类

    二、实例

      1: package org.lxh.demo;
      2: 
      3: import android.app.Activity;
      4: import android.os.Bundle;
      5: import android.widget.EditText;
      6: 
      7: public class MyEditTextDemo extends Activity {
      8: 	private EditText edit = null; // 作为属性出现
      9: 
     10: 	@Override
     11: 	public void onCreate(Bundle savedInstanceState) {
     12: 		super.onCreate(savedInstanceState);
     13: 		super.setContentView(R.layout.main);
     14: 		this.edit = (EditText) super.findViewById(R.id.myet2); // 取得组件
     15: 		this.edit.setEnabled(false) ;	// 现在不可编辑
     16: 	}
     17: }


      1: <?xml version="1.0" encoding="utf-8"?>
    
      2: <LinearLayout 
    
      3: 	xmlns:android="http://schemas.android.com/apk/res/android"
    
      4: 	android:orientation="vertical" 
    
      5: 	android:layout_width="fill_parent"
    
      6: 	android:layout_height="fill_parent">
    
      7: 	<!-- 
    
      8: 	selectAllOnFocus:默认全选状态且获得焦点,
    
      9: 	numeric:指定只可输入数字,不指定的话什么字符都可以输入
    
     10: 	可以设置android:enabled来指定不可编辑状态
    
     11: 	 -->
    
     12: 	<EditText 
    
     13: 		android:id="@+id/myet1"
    
     14: 		android:layout_width="fill_parent"
    
     15: 		android:layout_height="wrap_content" 
    
     16: 		android:text="北京魔乐科技软件学院(MLDN)" 
    
     17: 		android:selectAllOnFocus="true"/>
    
     18: 	<EditText 
    
     19: 		android:id="@+id/myet2"
    
     20: 		android:layout_width="fill_parent"
    
     21: 		android:layout_height="wrap_content" 
    
     22: 		android:text="网址:www.mldnjava.cn" 
    
     23: 		/>
    
     24: 	<EditText 
    
     25: 		android:id="@+id/myet3"
    
     26: 		android:layout_width="fill_parent"
    
     27: 		android:layout_height="wrap_content" 
    
     28: 		android:password="true"
    
     29: 		android:text="用户登录密码" />
    
     30: 	<EditText 
    
     31: 		android:id="@+id/myet4"
    
     32: 		android:layout_width="fill_parent"
    
     33: 		android:layout_height="wrap_content" 
    
     34: 		android:numeric="integer"
    
     35: 		android:text="51283346" />
    
     36: </LinearLayout>
    
     37: 

              image
  • 相关阅读:
    anaconda3 notebook for python数据分析-环境搭建
    MySQL之day4
    MySQL之day3
    MySQL之day2
    综合大实验(按需求完成)
    策略路由实验ACL配置
    双点双向重分布实验
    OSPF实验isis协议的设置命令
    OSPFS实验流量优化
    OSPF实验大串连
  • 原文地址:https://www.cnblogs.com/hxsyl/p/3657873.html
Copyright © 2011-2022 走看看