Android控件之TextView和EditText
TextView:显示文本框控件
EditText:输入文本框
TextView和EditText的常用属性
TextView控件的常用属性
android:id 控件的id
android:layout_width 控件的宽度
android:layout_height 控件的高度
android:text 文本内容
android:textSize 文本大小
android:textColor 文本颜色
android:background 控件背景
EditText的常用属性除了和TextView相同的这些常用属性外,还包括:
android:hint 输入提示文本
android:inputType 输入文本类型
在main_activity中插入TextView和EditText信息:

wrap_content:包裹实际文本内容
match_parent:当前控件铺满父类容器:2.3api之后添加的一个属性值
fill_parent:当前控件铺满父类容器:2.3api之前的一个属性值

TextView:

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
android:textSize="28sp"
android:textColor="#00FF00"
/>

EditText:

<EditText
android:hint="请输入你的姓名"
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.textviewedittext.MainActivity$PlaceholderFragment"
android:orientation="horizontal"
> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
android:textSize="28sp"
android:textColor="#00FF00"
/> <EditText
android:hint="请输入你的姓名"
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
> <requestFocus />
</EditText> </LinearLayout>

fragment_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.textviewedittext.MainActivity"
tools:ignore="MergeRootFrame" />

activity_main.xml(没有改动)

package com.example.textviewedittext;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build; public class MainActivity extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
} @Override
public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
} /**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment { public PlaceholderFragment() {
} @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
} }

MainActivity.java(没有改动)

效果:

Android 在界面中显示以及输入文本信息 TextView和EditText的更多相关文章

  1. Android Device Chooser中显示Target unknown解决方法

    手机插在电脑上准备调试程序来着,通过eclipse运行时,弹出的Android Device Chooser中显示设备名是?????,Target未知,无法继续运行. 可以通过以下步骤解决(Ubunt ...

  2. 【ABAP系列】SAP 业务界面同时显示KEY和文本

      公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP 业务界面同时显示KEY和 ...

  3. 教你一招:在PowerPoint中自定义可输入文本的占位符

    日常生活中,当我们设计多媒体课件时,默认的版式其实已经够用了.但是,很多时候,我们需要更加个性一点,所以,我们需要自定义很多东西.本文介绍在PowerPoint中自定义可输入文本的占位符. 一.占位符 ...

  4. [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget (第一部分)

    本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...

  5. 微信小程序中显示html富文本的方法

    微信小程序中显示html富文本的方法 使用方法:git地址:https://github.com/icindy/wxParse 一.下载wxParse文件 二.在要引入的页面的js文件中,引入文件 j ...

  6. 在Installshield的安装进度中显示自己设置的信息

    原文:在Installshield的安装进度中显示自己设置的信息 以Installscript msi project为例,在installshield所制作的安装包安装过程中显示安装进度的,就在On ...

  7. [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget(第二部分)

    本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...

  8. Android在Service中显示Dialog

    在Service中弹出一个Dialog对话框 第1步:在应用的AndroidManifest.xml中需要添加权限.没有无法显示. <uses-permission android:name=& ...

  9. 学习Android,最简单的按钮提示文本信息

    最近都在看Android系统架构跟四大组件,刚开始自己看书看网络资料,简直就是一脸懵,今天在这里对初学者,或者自学的同学,可以跟着我来学习,Android 编码一个按钮出发事件的小案例: 当然,在此之 ...

随机推荐

  1. Java调用存储过程小结

    学生在学习jdbc的时候,会问到怎么调用存储过程,现在将java调用oracle存储过程的示例总结如下.(关于调用sqlserver的存储过程将在下次进行小结请关注) 一:无返回值的存储过程 存储过程 ...

  2. 激活JetBrains的IDE(PhpStorm、WebStorm、IntelliJ IDEA)

    JetBrains 授权服务器(License Server URL): http://idea.imsxm.com/ 转自: http://www.imsxm.com/jetbrains-licen ...

  3. Linux 网络子系统之网络协议接口层(二)

    这一篇主要围绕网络协议接口层的发送函数的解析 int dev_queue_xmit(struct sk_buff *skb) 函数解析 声明: /* include/linux/netdevice.h ...

  4. 第一次使用bootstrap3做的响应式网站

    第一次使用bootstrap3,发现对移动支持得不错,可以很快的开发出一个支持移动和PC端的网站 作为一个后台程序员觉得得界面做得还可以, 按以前是只能自己看看了 时间线来自国外网站,使用到的css如 ...

  5. 分布式系统技术系列--租约(lease) (转载)

    租约(lease)在英文中的含义是“租期”.“承诺”,在分布式中一般描述如下: Lease 是由授权者授予的在一段时间内的承诺. 授权者一旦发出 lease,则无论接受方是否收到,也无论后续接收方处于 ...

  6. 第一关练习题统计网站最大访问量sed法,隐藏知识数组下标不能重复

    1.1.1 获取日志的最大top10,排序 获取两列到新的文件中第一次处理 sed截取字符串中间的内容,sed不支持贪婪匹配.找出图片在的列和图片大小到test1文件 本题需要输出三个指标:[访问次数 ...

  7. FastDFS - 文件服务器学习资料

    FastDFS搭建及java整合代码 CentOS 6.5下 FastDFS结合Nginx插件实现图片http访问 图片服务器fastDFS的搭建以及配置 nginx fastdfs 配置后 上传成功 ...

  8. IXWebHosting主机如何退款中文图解教程

    http://www.chinaz.com/web/2011/0630/192654.shtml ——————————————————————————————————————————————————— ...

  9. Namenode HA原理详解

    社区hadoop2.2.0 release版本开始支持NameNode的HA,本文将详细描述NameNode HA内部的设计与实现. 为什么要Namenode HA? 1. NameNode High ...

  10. php 不依赖数据实现删除图片,核心代码

    <?php $file = "ueditor\php\upload\image\*\*.png"; foreach (glob("$file") as $ ...