Android学习笔记——Button
该工程的功能是实现在activity中显示一个TextView和一个Button
以下代码是MainActivity中的代码
package com.example.button; import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView myTextView = (TextView)findViewById(R.id.myTextView);
Button myButton = (Button)findViewById(R.id.myButton);
myTextView.setText("我的第一个TextView");
myButton.setText("我的第一个Button"); }
}
以下代码是activity_main中的代码
<RelativeLayout 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"
tools:context="${relativePackage}.${activityClass}" > <TextView
android:id="@+id/myTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <Button
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/> </RelativeLayout>
Android学习笔记——Button的更多相关文章
- Android学习笔记-Button(按钮)
		
Button是TextView的子类,所以TextView上很多属性也可以应用到Button 上!我们实际开发中对于Button的,无非是对按钮的几个状态做相应的操作,比如:按钮按下的时候 用一种颜色 ...
 - Android学习笔记进阶之在图片上涂鸦(能清屏)
		
Android学习笔记进阶之在图片上涂鸦(能清屏) 2013-11-19 10:52 117人阅读 评论(0) 收藏 举报 HandWritingActivity.java package xiaos ...
 - android学习笔记36——使用原始XML文件
		
XML文件 android中使用XML文件,需要开发者手动创建res/xml文件夹. 实例如下: book.xml==> <?xml version="1.0" enc ...
 - Android学习笔记之JSON数据解析
		
转载:Android学习笔记44:JSON数据解析 JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,为Web应用开发提供了一种 ...
 - 【转】Pro Android学习笔记(九八):BroadcastReceiver(2):接收器触发通知
		
文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处:http://blog.sina.com.cn/flowingflying或作者@恺风Wei-傻瓜与非傻瓜 广播接 ...
 - 【转】 Pro Android学习笔记(七七):服务(2):Local Service
		
目录(?)[-] Local service代码 调用Local ServiceLocal Service client代码 AndroidManifestxml定义Serviceacitivty的l ...
 - 【转】 Pro Android学习笔记(七四):HTTP服务(8):使用后台线程AsyncTask
		
目录(?)[-] 5秒超时异常 AsyncTask 实现AsyncTask抽象类 对AsyncTask的调用 在哪里运行 其他重要method 文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注 ...
 - 【转】 Pro Android学习笔记(七五):HTTP服务(9):DownloadManager
		
目录(?)[-] 小例子 保存在哪里下载文件信息设置和读取 查看下载状态和取消下载 文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件,转载须注明出处:http://blog.csd ...
 - 【转】 Pro Android学习笔记(五七):Preferences(1):ListPreference
		
目录(?)[-] 例子1ListPreference小例子 定义一个preferences XML文件 继承PreferenceActivity 用户定制偏好的读取 第一次运行时设置缺省值 设置Cat ...
 
随机推荐
- [转]理解RESTful架构
			
原文地址:http://www.ruanyifeng.com/blog/2011/09/restful 越来越多的人开始意识到,网站即软件,而且是一种新型的软件. 这种"互联网软件" ...
 - 离线安装redis集群
			
Step0:redis集群组件需求 Step1:离线安装ruby Step2:离线安装rubygems Step3:安装rubygems的 redis api Step4:离线安装tcl 8.6 St ...
 - Js-字符串截取substring,分割split,指标indexOf,拼接John
			
函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组例子: var theString=”jpg|bmp|gif|ico|png”; var arr=theString.spli ...
 - How to fix the sources list
			
How to fix the sources list Sometimes the apt-get may not work, it is often caused by the misspelled ...
 - Cocoa pod的使用注意点
			
一.CocoaPods是什么? CocoaPods是一个负责管理iOS项目中第三方开源库的工具.CocoaPods的项目源码在Github上管理.该项目开始于2011年8月12日,在这两年多的时间里, ...
 - Bzoj2434 [Noi2011]阿狸的打字机
			
Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 2536 Solved: 1415 Description 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到 ...
 - sublime配置java编译环境
			
Windows下配置Sublime Text3的Java环境 字数507 阅读2301 评论2 喜欢2 Sublime Text3是一个比较好用的IDE.截图如下: java环境截图 下面就简单介绍下 ...
 - Java过滤器与SpringMVC拦截器之间的关系与区别
			
今天学习和认识了一下,过滤器和SpringMVC的拦截器的区别,学到了不少的东西,以前一直以为拦截器就是过滤器实现的,现在想想还真是一种错误啊,而且看的比较粗浅,没有一个全局而又细致的认识,由于已至深 ...
 - Centos提示-bash: make: command not found的解决办法
			
一般出现这个-bash: make: command not found提示,是因为安装系统的时候使用的是最小化mini安装,系统没有安装make.vim等常用命令,直接yum安装下即可: yum - ...
 - Groupby - collection processing
			
Groupby - collection processing Iterator and Iterable have most of the most useful methods when deal ...