1、activity_main.xml

  描述:构建一个按钮

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:onClick="test_1"/> </LinearLayout>

2、MainActivity.java

  描述:页面跳转

package com.example.android_ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} public void test_1(View view){
Intent intent=new Intent(this,TextViewActivity.class);
startActivity(intent);
}
}

3、修改res资源目录下的values包中的strings.xml文件

  描述:

    在activity_text_view.xml文件中会应用 15015910994 这个电话号码  

<resources>
<string name="app_name">Android_UI</string>
<string name="police">15019948551</string> <array name="jobs">
<item>法师</item>
<item>坦克</item>
<item>射手</item>
<item>刺客</item>
</array>
</resources>

3、activity_text_view.xml

  描述:

    第一个TextView中:

      1、android:autoLink="phone"  表示自动拨打电话

      2、android:text="@string/police" 表示引用strings.xml文件中的电话号码

    第二个TextView中:

      1、android:autoLink="web"  表示自动打开网址

      2、android:text="http://192.168.0.168"  设置网络地址

    第三个EditText组件中:

      1、android:maxLines="1"  设置用户输入的信息不换行,即用户输入的信息只能在一行显示

      2、android:inputType="phone"  设置该输入框只能输入电话号码,即数字

    第四个EditText组件中:

      1、android:inputType="text"  设置该输入框只能输入文本内容

    第五个EditText组件中:

      1、android:inputType="textPassword"设置该输入框中只能输入密码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/police"
android:textSize="30sp"
android:gravity="center"
android:autoLink="phone"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="http://192.168.0.168"
android:textSize="30sp"
android:gravity="center"
android:autoLink="web"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:hint="请输入电话号码"
android:maxLines="1"
android:inputType="phone"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:hint="请输入姓名"
android:maxLines="1"
android:inputType="text"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:hint="请输密码"
android:maxLines="1"
android:inputType="textPassword"
/>
</LinearLayout>

4、TextViewActivity.java

  描述:无操作

package com.example.android_ui;

import android.app.Activity;
import android.os.Bundle; public class TextViewActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_view);
}
}

Android开发---基本UI组件1:自动拨电话,自动上网,输入框不换行、只输数字、只输文本、只输密码的更多相关文章

  1. Android开发 ---基本UI组件4:拖动事件、评分进度条、圆圈式进度条、进度条控制

    Android开发 ---基本UI组件4 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding=" ...

  2. Android开发 ---基本UI组件3:单选按钮、多选按钮、下拉列表、提交按钮、重置按钮、取消按钮

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个用户注册按钮 <?xml version="1.0" encoding=&q ...

  3. Android开发 ---基本UI组件2:图像按钮、单选按钮监听、多选按钮监听、开关

    Android开发 ---基本UI组件2 1.activity_main.xml 描述: 定义一个按钮 <?xml version="1.0" encoding=" ...

  4. Android开发 ---基本UI组件8:九宫格布局、setOnItemClickListener()项被选中监听事件

    效果图: 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding="utf-8"?> ...

  5. Android开发 ---基本UI组件6 :只定义一个listView组件,然后通过BaseAdapter适配器根据数据的多少自行添加多个ListView显示数据

    效果图: 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding="utf-8"?> ...

  6. Android开发 ---基本UI组件7 :分页功能、适配器、滚动条监听事件

    效果图: 1.activity_main.xml 描述: 定义了一个按钮 <?xml version="1.0" encoding="utf-8"?> ...

  7. Android开发 ---基本UI组件5:监听下拉选项,动态绑定下拉选项、全选/反选,取多选按钮的值,长按事件,长按删除,适配器的使用,提示查询数据,activity控制多按钮

    效果图: 效果描述: 1.当点击 1 按钮后,进入选择城市的页面,会监听到你选中的城市名称:动态为Spinner绑定数据 2.当点击 2 按钮后,进入自动查询数据页面,只要输入首字母,就会动态查找以该 ...

  8. ReactNative Android之原生UI组件动态addView不显示问题解决

    ReactNative Android之原生UI组件动态addView不显示问题解决 版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请表明出处:http://www.cnblogs.com ...

  9. android开发之自定义组件

    android开发之自定义组件 一:自定义组件: 我认为,自定义组件就是android给我们提供的的一个空白的可以编辑的图片,它帮助我们实现的我们想要的界面,也就是通过自定义组件我们可以把我们要登入的 ...

随机推荐

  1. English Voice of << Last Christmas >>

    Last Christmas填 词:乔治·迈克尔谱 曲:乔治·迈克尔编 曲:乔治·迈克尔歌词:Last Christmas I gave you my heart去年的圣诞节,我把心给了你But th ...

  2. Stanford: Creating a Hadoop-2.x project in Eclipse

    Creating a Hadoop-2.x project in Eclipse http://snap.stanford.edu/class/cs246-data-2014/hw0.pdf Hado ...

  3. android -------- 安装APK报错:Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE解决方法

    记录一个 DELETE_FAILED_INTERNAL_ERROR Error while Installing APK问题 之前遇到这个问题 方案1 将data/data/目录下该应用的包名的目录删 ...

  4. python—变量和简单数据类型

    1.变量 在程序中可随时修改变量的值,python始终记录变量的最新值 变量名:必须以字母或者下划线开头,只能包含字母数字和下划线,建议使用下划线+小写字母的方式命名,不能为函数名和python关键字 ...

  5. ZCU板级调试Bug记录

    本帖用以记录在ZCU102板级调试间遇到的Bug. 1.PL端的AXI总线在读取DDR中的数据的时候,在一个burst内不能跨越page boundary.跨越page boundary会在该burs ...

  6. 牛客练习赛24-B-贪心

    链接:https://www.nowcoder.com/acm/contest/157/B来源:牛客网 题目描述 凤凰于飞,翙翙其羽,亦集爰止.                             ...

  7. python 常用代码

    获取标签名 h1 class 是h1usersoup.find(name="h1", attrs={"class":"h1user"});获 ...

  8. github上fork了别人的项目后,再同步更新别人的提交(转)

    原文地址:github上fork了别人的项目后,再同步更新别人的提交 我从github网站和用git命令两种方式说一下. github网站上操作 打开自己的仓库,进入code下面. 点击new pul ...

  9. django学习之——模版

    为了减少模板加载调用过程及模板本身的冗余代码,Django 提供了一种使用方便且功能强大的 API ,用于从磁盘中加载模板, 要使用此模板加载API,首先你必须将模板的保存位置告诉框架. 设置的保存文 ...

  10. 从使用角度看 ReentrantLock 和 Condition

    java 语言中谈到锁,少不了比较一番 synchronized 和 ReentrantLock 的原理,本文不作分析,只是简单介绍一下 ReentrantLock 的用法,从使用中推测其内部的一些原 ...