啦啦啦~ 我是qscqesze 今天开始android的从零单排啦啦啦~

首先从最简单的开始

要求:

程序运行后,单击屏幕上的按键后可以显示一句话,如“HelloWorld

这是一个最基础最基础的东东啦,我就不怎么废话了

代码如下:

//java文件package com.example.helloworld;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.TextureView;import android.view.View;import android.view.View.OnClickListener;import android.widget.TextView;public class MainActivity<Button> extends Activity {    Button b;    TextView t;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);                b=(Button) this.findViewById(R.id.button1);        t=(TextView) this.findViewById(R.id.textView1);                ((View) b).setOnClickListener(new OnClickListener(){            public void onClick(View v){                t.setText("Hello World");            }        });    }}

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: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=".MainActivity" >    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="" />    <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/textView1"        android:layout_centerHorizontal="true"        android:layout_marginTop="134dp"        android:text="来点我" /></RelativeLayout>

源码文件以及裁图:http://pan.baidu.com/s/1nt7fIu1

更多相关文章

  1. Android(安卓)如何在关于手机界面添加个图片
  2. git使用小结
  3. Android第四个功能:文件读取,并且用单元测试进行测试
  4. Weex系列(序) —— 总要知道原生的一点东东(Android)
  5. Android中存储目录
  6. 向sdcard添加文件fail可能的情况
  7. [2010-12-31 21:33:29 - s] W/ResourceType(27930): Unable to g
  8. Android(安卓)数据存储之 文件存储
  9. make_ext4fs 文件权限控制

随机推荐

  1. Mac AndroidStudio真机调试
  2. 关于单选框RadioGroup和RadioButton
  3. Android引路蜂地图开发示例:第一个地图应
  4. android手机图片查看
  5. Android(安卓)- Looper.prepare()和Loope
  6. runONUIThread 分析与使用
  7. Android NDK之JNI使用例子
  8. Android之android:theme设置在Applicatio
  9. 深入了解android平台的jni(二)
  10. Android弹出软键盘布局是否上移问题