/layout/activity_main.xml
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <TextView
android:id="@+id/mytext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/mybtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/> </RelativeLayout>
com.example.demo01textviewbutton.MainActivity
package com.example.demo01textviewbutton; import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; //当在/layout/activity_main.xml中加控件后,R会自动生成相应的资源文件ID
public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//编写相应业务逻辑
TextView textView = (TextView) super.findViewById(R.id.mytext);
textView.setText("buy big house");
Button mybutton=(Button)super.findViewById(R.id.mybtn);
mybutton.setText("clink me ,xixihehehaha");
} @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;
} }
R.java中生成以下:   
public static final class id {
public static final int action_settings=0x7f080002;
public static final int mybtn=0x7f080001;
public static final int mytext=0x7f080000;
}

android_demo01的更多相关文章

随机推荐

  1. Bluetooth LMP介绍

    目录 1. 介绍 2. 数据包格式(Packet Format) 3. Procedure Rules 4. 通用回应消息(General Response Messages) 5. 设备特性(Dev ...

  2. GetLogicalProcessorInformation(XP3才支持)和GetLogicalProcessorInformationEx(WIN7才支持)

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms683194(v=vs.85).aspx 例子执行结果如下: https://ms ...

  3. .NET 可空值类型

    Microsoft在CLR中引入了可空值类型(nullable value type)的概念. FCL中定义System.Nullable<T>类如下: [Serializable,Str ...

  4. VB的注释

    VB程序中的注解有两种: 第1种是以单引号 ' 开头的,但如果这个符号是在双引号之内的,则视为文本,不做为注释引导符,这个符号后面的内容均为注释内容. 第2种就REM后加注释内容(REM与注释内容要空 ...

  5. 对象(List<T>)的序列化和反序列化

    本文描述将对象(List<T>)序列化到 XML 文档中和从 XML 文档中反序列化为对象(List<T>). 命名空间: System.Xml.Serialization 程 ...

  6. Cocos2d-JS工程中的文件结构

    res文件夹存放资源文件 src文件夹是主要的程序代码 app.js是实现游戏场景的JavaScript文件 resource.js在src文件夹中,定义资源对应的变量 config.json保存模拟 ...

  7. (读书笔记)Asp.net Mvc 与WebForm 混合开发

    根据项目实际需求,有时候会想在项目中实现Asp.net Mvc与Webform 混合开发,比如前台框架用MVC,后台框架用WebForm.其实要是实现也很简单,如下: (1)在MVC 中使用Webfo ...

  8. iOS7上TableViewCell的button和UIImageView个别未显示的bug

    要做这个cell,用xib将cell做成之后,在iPhone6.6Plus.5s上运行良好,但是在iOS7的5s和iPad上,黄色的小星星和下载按钮均没有显示. 甚为惊奇. 在网上百度之,发现了解决办 ...

  9. Asp.net MVC4 网站发布

    1.打开你的VS2012网站项目,右键点击项目-->发布: 2.弹出网站发布设置面板,点击<新建..>创建新的发布配置文件: 3.输入配置文件名称:(名称随便) 3.在发布方法中选“ ...

  10. centos7安装openvswitch虚拟交换机

    What is Open vSwitch? Open vSwitch is a production quality, multilayer virtual switch licensed under ...