/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. sqlserver 通过convert取得指定格式的时间

    http://msdn.microsoft.com/zh-cn/library/ms187928(v=sql.105).aspx CONVERT(NVARCHAR(10),Created,112) 不 ...

  2. QWidget 键盘事件 焦点(QApplication源码)

    在Qt中,键盘事件和QWidget的focus密不可分:一般来说,一个拥有焦点(focus)的QWidget或者grabKeyboard()的QWidget才可以接受键盘事件. 键盘事件派发给谁? 如 ...

  3. js严格模式“use strict”

    js的严格模式会放弃js中的一些不正规的写法,参考 http://www.cnblogs.com/God-Shell/p/3139329.html: 使用声明"use  strict&quo ...

  4. jade反编译

    安装html2jade npm install html2jade -g 反编译,默认输出同名jade html2jade test2.html 反编译为其他文件名 html2jade test2.h ...

  5. ArcGIS API for Silverlight 调用GP服务绘制等值面

    原文:ArcGIS API for Silverlight 调用GP服务绘制等值面 GP服务模型如下图: 示例效果图片如下:

  6. RTSP协议详解

        RTSP(Real Time Streaming Protocol)是由Real Network和Netscape共同提出的如何有效地在IP网络上传输流媒体数据的应用层协议.RTSP对流媒体提 ...

  7. A Framework for Programme Management

    In business today organisations manage multiple projects concurrently with shared or overlapping res ...

  8. swift-03-构造器(Designated&&Convenience)

    类里面所有的存储型属性--包括所有继承自父类的属性,都必须在构造过程中设置初始值.   构造器,为了确保所有类实例中的存储型属性都能获得初始值,设置了两个构造器--他们分别是指定构造器和便利构造器. ...

  9. Swift 遇到的报错信息

    第一个,没看懂.一开始还以为是不支持iOS7的缘故. dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /var ...

  10. Excl 的一些用法--如何给很多列赋同一个值

    1.用鼠标选定要负责的列(多列) 2.在处填写值 3.Ctrl+Enter